EXTERN Add Sub Put Get Open Exit Arg Prout Symb APPEND Lexer ENTRY Go

  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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
$EXTERN Add, Sub, Put, Get, Open, Exit, Arg, Prout, Symb, APPEND, Lexer;
$ENTRY Go{
= <Open 'w' 2 <Arg 2>> : <Put 2 <MyUnLexer <Preprocessor <CheckWarning <Lexer <Arg 1>>>>>>;
/*= <Open 'w' 2 <Arg 2>><Put 2 <Lexer <Arg 1>>>;*/
}
Inc {
s.Arg = <Add 1 s.Arg>;
}
Dec {
s.Arg = <Sub s.Arg 1>;
}
MyUnLexer {
e.Arg = <UnLexer <KillBrackets e.Arg>>;
}
KillBrackets {
(s.Domen (s.Line s.Col) e.Arg)e.Tail = (s.Domen (s.Line s.Col) e.Arg) : <KillBrackets e.Tail>;
(e.Smth) e.SmthElse = <KillBrackets e.Smth e.SmthElse>;
e.Program = e.Program;
}
UnLexer {
(OpenCall (s.BeginLine s.BeginCol) e.Lex)(s.Domen1 (s.BeginLine s.BeginCol1) e.Lex1)e.Tail =
<PrintLex OpenCall (s.BeginLine s.BeginCol) e.Lex> : <UnLexer (s.Domen1 (s.BeginLine s.BeginCol1) e.Lex1)e.Tail>;
(Char (s.Line s.Col) s.Char) e.Tail =
'\''
<UnLexer-Char (Char (s.Line s.Col) s.Char) e.Tail>;
(s.Domen (s.BeginLine s.BeginCol) e.Lex) (s.Domen1 (s.BeginLine s.BeginCol1) e.Lex1)e.Tail =
<PrintLex s.Domen (s.BeginLine s.BeginCol) e.Lex>
' '
<UnLexer (s.Domen1 (s.BeginLine s.BeginCol1) e.Lex1)e.Tail>;
(s.Domen (s.BeginLine s.BeginCol) e.Lex)(s.Domen1 (s.BeginLine1 s.BeginCol1) e.Lex1)e.Tail =
<PrintLex s.Domen (s.BeginLine s.BeginCol) e.Lex>
<NewLines s.BeginLine s.BeginLine1>
<UnLexer (s.Domen1 (s.BeginLine1 s.BeginCol1) e.Lex1)e.Tail>;
(EOF (e.BeginLine e.BeginCol) e.Lex) = ;
}
NewLines {
'-' e.Result = ;
s.Line1 s.Line2 = <NewLines <Sub s.Line2 s.Line1> s.Line1 s.Line2>;
s.R s.Line1 s.Line2 = <DoNewLines s.Line1 s.Line2>;
}
DoNewLines {
s.Line s.Line = ;
s.Line1 s.Line2 = '\n' : <DoNewLines <Inc s.Line1> s.Line2>;
}
PrintLex {
Variable (s.BeginLine s.BeginCol) s.VarType (e.Lex) = s.VarType '.' e.Lex;
Error (s.Line s.Col) e.Message =
<Prout <Arg 1> ':' <Symb s.Line> ':' <Symb s.Col> ':Error ' e.Message>
<Exit 1>;
s.Domen (e.BeginLine e.BeginCol) e.Lex = e.Lex;
}
PrintChar {
'\n' = '\\n';
'\t' = '\\t';
'\\' = '\\\\';
'\'' = '\\\'';
s.Char = s.Char;
}
UnLexer-Char {
(Char (s.Line s.Col) s.Char) e.Tail =
<PrintChar s.Char> : <UnLexer-Char e.Tail>;
e.Tail = '\' : ' <UnLexer e.Tail>;
}
CheckWarning {
e.Pattern (Assign t.Pos1 e.Arg1)
(OpenBracket t.Pos2 e.Arg2) t.B1 (CloseBracket t.Pos3 e.Arg3)
(OpenCall t.Pos4 e.Arg4) t.B2 (CloseCall t.Pos5 e.Arg5) (Semicolon t.Pos6 e.Arg6) e.R =
e.Pattern (Assign t.Pos1 e.Arg1)
(OpenBracket t.Pos2 e.Arg2) t.B1 (CloseBracket t.Pos3 e.Arg3)
(OpenCall t.Pos4 e.Arg4)t.B2 (CloseCall t.Pos5 e.Arg5)
(Semicolon t.Pos6 e.Arg6)
<Prout 'warning 1 on ' t.Pos1>
<Prout
(Assign t.Pos1 e.Arg1)
(OpenBracket t.Pos2 e.Arg2) t.B1 (CloseBracket t.Pos3 e.Arg3)
(OpenCall t.Pos4 e.Arg4) t.B2 (CloseCall t.Pos5 e.Arg5)
(Semicolon t.Pos6 e.Arg6)
>
<CheckWarning e.R>;
e.Pattern (Assign t.Pos1 e.Arg1)
(OpenCall t.Pos4 e.Arg4) e.B2 (CloseCall t.Pos5 e.Arg5)
(OpenBracket t.Pos2 e.Arg2) e.B1 (CloseBracket t.Pos3 e.Arg3)
e.Tail (Semicolon t.Pos6 e.Arg6) e.R =
e.Pattern (Assign t.Pos1 '=')
(OpenCall t.Pos4 '<') e.B2 (CloseCall t.Pos5 '>')
(OpenBracket t.Pos2 '(') e.B1 (CloseBracket t.Pos3 ')')
e.Tail (Semicolon t.Pos6 ';')
<Prout 'warning 2 on ' t.Pos1>
<CheckWarning e.R>;
e.Pattern (Assign t.Pos1 e.Arg1)
(OpenBracket t.Pos4 e.Arg4) e.B2 (CloseBracket t.Pos5 e.Arg5)
(OpenBracket t.Pos2 e.Arg2) e.B1 (CloseBracket t.Pos3 e.Arg3)
(Semicolon t.Pos6 e.Arg6) e.R =
e.Pattern (Assign t.Pos1 '=')
(OpenBracket t.Pos4 '(') e.B2 (CloseBracket t.Pos5 ')')
(OpenBracket t.Pos2 '(') e.B1 (CloseBracket t.Pos3 ')')
(Semicolon t.Pos6 ';')
<Prout 'warning 3 on ' t.Pos5 t.Pos2>
<CheckWarning e.R>;
e.Pattern (Assign t.Pos1 e.Arg1)
(OpenCall t.Pos2 e.Arg2) e.B1 (CloseCall t.Pos3 e.Arg3)
(OpenCall t.Pos4 e.Arg4) e.B2 (CloseCall t.Pos5 e.Arg5)
(Semicolon t.Pos6 e.Arg6) e.R =
e.Pattern (Assign t.Pos1 e.Arg1)
(OpenCall t.Pos2 e.Arg2) e.B1 (CloseCall t.Pos3 e.Arg3)
(OpenCall t.Pos4 e.Arg4) e.B2 (CloseCall t.Pos5 e.Arg5)
(Semicolon t.Pos6 e.Arg6)
<Prout 'warning 4 on ' t.Pos3 t.Pos4>
<CheckWarning e.R>;
e.Pattern (Assign t.Pos1 e.Arg1)
(Char t.Pos2 e.Arg2)
(OpenCall t.Pos4 e.Arg4) e.B2 (CloseCall t.Pos5 e.Arg5)
(Semicolon t.Pos6 e.Arg6) e.R =
e.Pattern (Assign t.Pos1 e.Arg1)
(Char t.Pos2 e.Arg2)
(OpenCall t.Pos4 e.Arg4) e.B2 (CloseCall t.Pos5 e.Arg5) (Semicolon t.Pos6 e.Arg6)
<Prout 'warning 5 on ' t.Pos2 t.Pos4>
<CheckWarning e.R>;
e.Pattern (Assign t.Pos1 e.Arg1) (Char t.Pos2 e.Arg2) (Char t.Pos3 e.Arg3) t.Tail (Semicolon t.Pos6 e.Arg6) e.R =
e.Pattern (Assign t.Pos1 e.Arg1) (Char t.Pos2 e.Arg2) (Char t.Pos3 e.Arg3) t.Tail (Semicolon t.Pos6 e.Arg6)
<Prout 'warning 6 on ' t.Pos2 t.Pos3>
<CheckWarning e.R>;
e.Program = e.Program;
}
Preprocessor {
(Assign t.Pos e.Assign) e.Program =
(Assign t.Pos e.Assign) : <Preprocessor-Result (L) e.Program>;
(Ref t.PosRef e.Ref) (Name t.PosName e.Name) e.Program =
(Name t.PosName 'Fn' e.Name) : <Preprocessor e.Program>;
(OpenCall t.PosCall e.OpenCall) (Name t.PosName e.Name) e.Program =
(OpenCall t.PosCall e.OpenCall)
(Name t.PosName 'Fn' e.Name)
<Preprocessor e.Program>;
(Name t.PosName e.Name) (OpenBlock t.PosBlock e.OpenBlock) e.Program =
(Name t.PosName 'Fn' e.Name)
(OpenBlock t.PosBlock e.OpenBlock)
<Preprocessor e.Program>;
(Directive t.Pos '$EXTERN') e.Program =
(Directive t.Pos '$EXTERN') : <Preprocessor-Extern e.Program>;
(Name t.PosName e.Name) e.Program =
(Name t.PosName 'Id' e.Name) : <Preprocessor e.Program>;
t.OtherToken e.Program = t.OtherToken : <Preprocessor e.Program>;
= ;
}
Preprocessor-Result {
((e.S1 (OpenCall t.Pos3 '<') e.S2 (CloseCall t.Pos2 '>') (Colon t.Pos1 ':')) t.Arg2Token) e.T =
<Preprocessor-Result
((e.S1 (Name t.Pos1 'APPEND')) (OpenCall t.Pos3 '<') e.S2 (CloseCall t.Pos2 '>') t.Arg2Token) e.T
>;
((e.S1 (OpenBracket t.Pos3 '(') e.S2 (CloseBracket t.Pos2 ')') (Colon t.Pos1 ':')) t.Arg2Token) e.T =
<Preprocessor-Result
((e.S1 (Name t.Pos1 'APPEND')) (OpenBracket t.Pos3 '(') e.S2 (CloseBracket t.Pos2 ')') t.Arg2Token) e.T
>;
((e.S t.Arg1Token (Colon t.Pos1 ':')) t.Arg2Token) e.T =
<Preprocessor-Result
((e.S (Name t.Pos1 'APPEND')) t.Arg1Token t.Arg2Token) e.T
>;
((e.S)) (Variable t.Pos1 e.Arg) e.T =
<Preprocessor-Result
((e.S)(Name t.Pos1 'Mu')) (Variable t.Pos1 e.Arg) e.T
>;
((e.S)) (Name t.Pos1 e.Arg) e.T =
<Preprocessor-Result
((e.S)(Name t.Pos1 'Fn' e.Arg)) e.T
>;
(e.S) (OpenCall t.Pos1 '<') e.T = <Preprocessor-Result ((e.S)) e.T>;
((e.S (Name t.Pos1 'APPEND')) (OpenBracket t.Pos3 '(') e.S2 (CloseBracket t.Pos2 ')') t.FnName e.1) (CloseCall t.Pos4 '>') e.T =
<Preprocessor-Result
(e.S (OpenCall t.Pos1 '<') (Name t.Pos1 'APPEND')
(OpenBracket t.Pos3 '(') e.S2 (CloseBracket t.Pos2 ')')
(OpenBracket t.Pos1 '(')(OpenCall t.Pos1 '<') t.FnName e.1 (CloseCall t.Pos2 '>')(CloseBracket t.Pos2 ')')
(CloseCall t.Pos4 '>')) e.T
>;
((e.S (Name t.Pos1 'APPEND')) (OpenCall t.Pos3 '<') e.S2 (CloseCall t.Pos2 '>') t.FnName e.1) (CloseCall t.Pos4 '>') e.T =
<Preprocessor-Result
(e.S (OpenCall t.Pos1 '<') (Name t.Pos1 'APPEND')
(OpenCall t.Pos3 '<') e.S2 (CloseCall t.Pos2 '>')
(OpenBracket t.Pos1 '(')(OpenCall t.Pos1 '<') t.FnName e.1 (CloseCall t.Pos2 '>')(CloseBracket t.Pos2 ')')
(CloseCall t.Pos4 '>')) e.T
>;
((e.S (Name t.Pos1 'APPEND')) t.Arg1Token t.FnName e.1) (CloseCall t.Pos2 '>') e.T =
<Preprocessor-Result
(e.S (OpenCall t.Pos1 '<') (Name t.Pos1 'APPEND')
t.Arg1Token (OpenBracket t.Pos1 '(')(OpenCall t.Pos1 '<') t.FnName e.1 (CloseCall t.Pos2 '>')(CloseBracket t.Pos2 ')')(CloseCall t.Pos2 '>')) e.T
>;
((e.S) (s.Domen t.Pos1 e.Arg) e.1) (CloseCall t.Pos2 '>') e.T =
<Preprocessor-Result
(e.S (OpenCall t.Pos1 '<') (s.Domen t.Pos1 e.Arg) e.1 (CloseCall t.Pos2 '>')) e.T
>;
(L e.S) (Semicolon t.Pos1 ';') e.T =
e.S (Semicolon t.Pos1 ';') : <Preprocessor e.T>;
((e.S) e.1) (Semicolon t.Pos1 ';') e.T =
e.S (Error t.Pos1 'Unbalanced brackets in expression' ) (Semicolon t.Pos1 ';') <Preprocessor e.T>;
(e.S) (Name t.Pos1 e.Arg) e.T =
<Preprocessor-Result (e.S (Name t.Pos1 'Id' e.Arg)) e.T>;
(e.S) t.Token e.T =
<Preprocessor-Result (e.S t.Token) e.T>;
}
Preprocessor-Extern {
(Name t.Pos e.Name) e.Program =
(Name t.Pos 'Fn' e.Name) : <Preprocessor-Extern e.Program>;
(Comma t.Pos e.Comma) e.Program =
(Comma t.Pos e.Comma) : <Preprocessor-Extern e.Program>;
(Semicolon t.Pos e.Semicolon) e.Program =
(Semicolon t.Pos e.Semicolon) <Preprocessor e.Program>;
(s.Other t.Pos e.Attr) e.Program =
(Error t.Pos 'Unexpected token in $EXTERN:' s.Other e.Attr)
<Preprocessor (s.Other t.Pos e.Attr) e.Program>;
}