forked from LAG-Comp/LAG-Compiler-I
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Design.txt
137 lines (105 loc) · 2.06 KB
/
Design.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// type: integer, character, boolean, floating_point, double_precision
// If it's an array, preceeded by 'array of' or 'array2d of'
// e.g. <integer> <array of character> <array2d of boolean>
Global <type> var_name = value;
<type> var_name = value;
Array <type> of size 3 array_name = { value, value, value };
Matrix <type> of size 3 by 2 array_name = { {value, value}, {value, value}, {value, value} };
var_name = array_name(n);
array_name(n,m) = value;
//Function declaration
Load: function_name
Input: <type> <reference>|<copy> var_name, ...
Output: <type> output_name
{
// Code
}
//Function declaration
Load: function_name
Input: <void>
Output: <void>
{
// Code
}
//Function call
Execute function function_name();
Execute function function_name with( value, value2, value3 );
//Control structures
If EXPRESSION_IS_TRUE execute
{
// Code
}
Else if EXPRESSION_IS_TRUE execute
{
// Code
}
Else execute
{
// Code
}
While EXPRESSION_IS_TRUE repeat
{
// Code
}
Do
{
// Code
}
While EXPRESSION_IS_TRUE
// skip
For COUNTER from A to B execute
{
}
Case var_name
equals value:
{}
equals value:
{}
equals value:
{}
case not:
{}
Print var_name;
Print value;
Operadores tradicionais: () + / *
Operadores redefinidos:
>= -> is greater than or equal to
<= -> is lesser than or equal to
== -> is equal to
> -> is greater than
< -> is lesser than
% -> modulo
&& -> and
|| -> or
! -> not
0 -> false
1 -> true
[] reserved for piping
// Functions and stuff
// Main:
Starting up...
// Code
End of file.
# Comment #
18) split[ x > 6 ]( a, b )
Split a to b using criterion ( E(x) );
a = { 0, 1, 2, 3, 4, 5 };
b = {};
Split a to b using criterion ( x > 2 );
a = { 0, 1, 2 };
b = { 3, 4, 5 };
Split a to b using criterion ( true );
a = { };
b = { 0, 1, 2 };
19) merge( a, b )[ x == y ]
a = { 1, 2, 3, 4, 5 };
b = { 1, 3, 5, 7, 9 };
c = merge( a, b )[ x == y ]
Merge a with b to c using criterion ( E(x,y) );
c = { 1, 3, 5 }
PIPE
a = { 1,3,2 };
b = [ a | sort ]
... | split a to b using criterion E(x) ]
[ merge a with b using criterion E(x,y) | ...
\{ \$\$[^\{\}]*\}