проблема в распознавании скобочек и аппенда. попробую обернуть все в структурные скобочки

  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
$EXTERN Add, Get, Open, Exit, Arg, Prout, Symb, Append, Lexer;
$ENTRY Go{
= <Open 'w' 2 'preprocessed.cref'><Put 2 <UnLexer <Preprocessor <CheckWarning <Lexer <Arg 1>>>>>>;
}
Inc {
s.Arg = <Add 1 s.Arg>;
}
Dec {
s.Arg = <Sub s.Arg 1>;
}
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.P(Assign t.Pos1 e.Arg1)(OpenBracket t.Pos2 e.Arg2)e.B1(CloseBracket t.Pos3 e.Arg3)(OpenCall t.Pos4 e.Arg4)e.B2(CloseCall t.Pos5 e.Arg5)e.Tail(Semicolon t.Pos6 e.Arg6)e.R =
e.P(Assign t.Pos1 e.Arg1)(OpenBracket t.Pos2 e.Arg2)e.B1(CloseBracket t.Pos3 e.Arg3)(OpenCall t.Pos4 e.Arg4)e.B2(CloseCall t.Pos5 e.Arg5)e.Tail(Semicolon t.Pos6 e.Arg6)
<Prout 'warning on ' t.Pos1>
<CheckWarning e.R>;
e.P(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.P(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 on ' t.Pos1>
<CheckWarning e.R>;
e.P(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)e.Tail(Semicolon t.Pos6 e.Arg6)e.R =
e.P(Assign t.Pos1 '=')(OpenBracket t.Pos4 '(')e.B2(CloseBracket t.Pos5 ')')(OpenBracket t.Pos2 '(')e.B1(CloseBracket t.Pos3 ')')e.Tail(Semicolon t.Pos6 ';')
<Prout 'warning on ' t.Pos1>
<CheckWarning e.R>;
e.P(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)e.Tail(Semicolon t.Pos6 e.Arg6)e.R =
e.P(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)e.Tail(Semicolon t.Pos6 e.Arg6)
<Prout 'warning on ' t.Pos1>
<CheckWarning e.R>;
e.P(Assign t.Pos1 e.Arg1)(Char t.Pos2 e.Arg2)(OpenCall t.Pos4 e.Arg4)e.B2(CloseCall t.Pos5 e.Arg5)e.Tail(Semicolon t.Pos6 e.Arg6)e.R =
e.P(Assign t.Pos1 e.Arg1)(Char t.Pos2 e.Arg2)(OpenCall t.Pos4 e.Arg4)e.B2(CloseCall t.Pos5 e.Arg5)e.Tail(Semicolon t.Pos6 e.Arg6)
<Prout 'warning on ' t.Pos1>
<CheckWarning e.R>;
e.P(Assign t.Pos1 e.Arg1)(Char t.Pos2 e.Arg2)(Char t.Pos3 e.Arg3)e.Tail(Semicolon t.Pos6 e.Arg6)e.R =
e.P(Assign t.Pos1 e.Arg1)(Char t.Pos2 e.Arg2)(Char t.Pos3 e.Arg3)e.Tail(Semicolon t.Pos6 e.Arg6)
<Prout 'warning on ' t.Pos1>
<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.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') (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 '>')
(OpenCall t.Pos1 '<') t.FnName e.1 (CloseCall 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 (OpenCall t.Pos1 '<') t.FnName e.1 (CloseCall 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) 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>;
}