EXTERN Error LABEL Atom OpenBr ClseBr Brackets FORWARD ParseName Spar

 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
$EXTERN Error;
$LABEL S, E, T, Atom, OpenBr, ClseBr, Brackets;
$FORWARD ParseName;
Spar {
(e.S) (#OpenBr ) e.T = <Spar ((e.S)) e.T>;
((e.S) e.1) (#ClseBr ) e.T = <Spar (e.S (#Brackets e.1)) e.T>;
('L' e.S) (#ClseBr ) e.T = <Error 'Error while parsing brackets'>;
(e.S) (s.X e.attr) e.T = <Spar (e.S (s.X e.attr)) e.T>;
('L' e.S) = e.S;
(e.S) = <Error 'Error while parsing brackets'>;
}
MakeBrackets {
e.1 = <Spar ('L') e.1>;
}
PatternLexer {
'(' e.tail = (#OpenBr ) <PatternLexer e.tail>;
')' e.tail = (#ClseBr ) <PatternLexer e.tail>;
/* Variables */
's.' e.tail = <ParseName #S e.tail ()>;
't.' e.tail = <ParseName #T e.tail ()>;
'e.' e.tail = <ParseName #E e.tail ()>;
/* Skip WS */
' ' e.tail = <PatternLexer e.tail>;
'\t' e.tail = <PatternLexer e.tail>;
'\n' e.tail = <PatternLexer e.tail>;
s.Atom e.tail = (#Atom s.Atom) <PatternLexer e.tail>;
= ;
}
ParseName {
s.VarType '(' e.tail (e.name) =
(s.VarType (e.name) ()) <PatternLexer '(' e.tail>;
s.VarType ')' e.tail (e.name) =
(s.VarType (e.name) ()) <PatternLexer ')' e.tail>;
s.VarType ' ' e.tail (e.name) =
(s.VarType (e.name) ()) <PatternLexer e.tail>;
s.VarType '\t' e.tail (e.name) =
(s.VarType (e.name) ()) <PatternLexer e.tail>;
s.VarType '\n' e.tail (e.name) =
(s.VarType (e.name) ()) <PatternLexer e.tail>;
s.VarType (e.name) =
(s.VarType (e.name) ());
s.VarType s.symbol e.tail (e.name) =
<ParseName
s.VarType e.tail (e.name s.symbol)
>;
}
$ENTRY Parser {
e.patterns =
<MakeBrackets
<PatternLexer
e.patterns
>
>;
}