forked from sebastianriese/pyLR1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpyLRp.pyLRp
92 lines (68 loc) · 1.34 KB
/
pyLRp.pyLRp
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
# pyLRp grammar file for pyLRp
# this must be kept parsable with the limited bootstrap parser
# it is the definite reference on the format
%lexer
\#.*\n+ NEWLINE
\n\s+ NEWLINE
# no lexer stater are available in the pre-parser,
# space matters here and there (python code ...)
# therefore anyone who is whitespace ignorant: please notiy us
\s+ SPACE
\%restart RESTART
\%lexer LEXER
\%parser PARSER
.* ARBLINE
\".*\" TEXT
[A-Za-z_][A-Za-z0-9_]* SYMBOL
\<[A-Z]+\> STATE
# this could be more concrete
([^ \t]|\\ )+ REGEX
%parser
file:
%empty
file part
part:
header
lexer
parser
header:
%empty
header pycodeline
pycodeline:
NEWLINE
SPACE ARBLINE NEWLINE
lexer:
LEXER SPACE NEWLINE
lexerline
lexerline:
STATE SPACE REGEX SPACE lexeraction SPACE NEWLINE
REGEX SPACE lexeraction SPACE NEWLINE
lexeraction:
lexeraction1
lexeraction SPACE "," SPACE lexeraction1
lexeraction1:
RESTART
SYMBOL
BEGIN
END
APPEND
COLLECT
parser:
PARSER SPACE NEWLINE
rule
rule:
SYMBOL SPACE ":" SPACE rulebody
rulebody:
NEWLINE
NEWLINE SPACE EMPTY SPACE "{" action "}" SPACE NEWLINE
NEWLINE SPACE prod SPACE "{" action "}" SPACE NEWLINE
prod:
prod1
prod SPACE prod1
prod1:
SYMBOL
TEXT
# clean
action:
SPACE NEWLINE
action SPACE ARBLINE NEWLINE