-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
132 lines (104 loc) · 3.71 KB
/
grammar.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
S -> program symbol semicolon TOP-LEVEL-BLOCK
TOP-LEVEL-BLOCK -> BEGIN-END-BLOCK TOP-LEVEL-BLOCK-OR-END
TOP-LEVEL-BLOCK -> VAR-BLOCK TOP-LEVEL-BLOCK
TOP-LEVEL-BLOCK -> CONST-BLOCK TOP-LEVEL-BLOCK
TOP-LEVEL-BLOCK -> FUNCTION TOP-LEVEL-BLOCK
TOP-LEVEL-BLOCK -> PROCEDURE TOP-LEVEL-BLOCK
TOP-LEVEL-BLOCK-OR-END -> dot eof
TOP-LEVEL-BLOCK-OR-END -> semicolon TOP-LEVEL-BLOCK
FUNCTION -> function symbol ARGLIST colon symbol semicolon FUNC-PROC-BODY
FUNC-PROC-BODY -> forward semicolon
FUNC-PROC-BODY -> FUNCTION-BLOCKS& BEGIN-END-BLOCK semicolon
FUNCTION-BLOCKS& ->
FUNCTION-BLOCKS& -> VAR-BLOCK FUNCTION-BLOCKS&
FUNCTION-BLOCKS& -> CONST-BLOCK FUNCTION-BLOCKS&
PROCEDURE -> procedure symbol ARGLIST semicolon FUNC-PROC-BODY
FUNCALL -> symbol FUNCALL-ARGS
FUNCALL-ARGS -> lparen FUNCALL-ARGS-INNER rparen
FUNCALL-ARGS-INNER ->
FUNCALL-ARGS-INNER -> EXPR FUNCALL-ARGS-INNER2
FUNCALL-ARGS-INNER2 ->
FUNCALL-ARGS-INNER2 -> comma EXPR FUNCALL-ARGS-INNER2
NUMBER-ARRAY-INDEX -> number
NUMBER-ARRAY-INDEX -> sub number
ARRAY-DECL -> array lbracket NUMBER-ARRAY-INDEX dotdot NUMBER-ARRAY-INDEX rbracket of symbol
TYPE-SPECIFIER -> ARRAY-DECL
TYPE-SPECIFIER -> symbol
ARGLIST -> lparen ARGLIST-INNER rparen
ARGLIST-INNER ->
ARGLIST-INNER -> symbol colon symbol ARGLIST-INNER2
ARGLIST-INNER2 ->
ARGLIST-INNER2 -> semicolon symbol colon symbol ARGLIST-INNER2
CONST-BLOCK -> const CONST-DECL CONST-DECLS&
CONST-DECL -> symbol eq LITERAL semicolon
CONST-DECLS& ->
CONST-DECLS& -> CONST-DECL CONST-DECLS&
VAR-BLOCK -> var VAR-DECL VAR-DECLS&
VAR-DECL -> symbol VAR-NAMES& colon TYPE-SPECIFIER semicolon
VAR-NAMES& ->
VAR-NAMES& -> comma symbol VAR-NAMES&
VAR-DECLS& ->
VAR-DECLS& -> VAR-DECL VAR-DECLS&
INDEX-OP -> symbol lbracket EXPR rbracket
INDEX-OP-INNER -> lbracket EXPR rbracket
EXPR -> EXPR-OR
EXPR-OR -> EXPR-AND EXPR-OR'
EXPR-OR' ->
EXPR-OR' -> or EXPR-AND EXPR-OR'
EXPR-AND -> EXPR-EQ-NE EXPR-AND'
EXPR-AND' ->
EXPR-AND' -> and EXPR-EQ-NE EXPR-AND'
EXPR-EQ-NE -> EXPR-CMP EXPR-EQ-NE'
EXPR-EQ-NE' ->
EXPR-EQ-NE' -> eq EXPR-CMP EXPR-EQ-NE'
EXPR-EQ-NE' -> ne EXPR-CMP EXPR-EQ-NE'
EXPR-CMP -> EXPR-ADD EXPR-CMP'
EXPR-CMP' ->
EXPR-CMP' -> lt EXPR-ADD EXPR-CMP'
EXPR-CMP' -> le EXPR-ADD EXPR-CMP'
EXPR-CMP' -> gt EXPR-ADD EXPR-CMP'
EXPR-CMP' -> ge EXPR-ADD EXPR-CMP'
EXPR-ADD -> EXPR-MUL EXPR-ADD'
EXPR-ADD' ->
EXPR-ADD' -> add EXPR-MUL EXPR-ADD'
EXPR-ADD' -> sub EXPR-MUL EXPR-ADD'
EXPR-MUL -> EXPR-UNARY EXPR-MUL'
EXPR-MUL' ->
EXPR-MUL' -> mul EXPR-UNARY EXPR-MUL'
EXPR-MUL' -> div EXPR-UNARY EXPR-MUL'
EXPR-MUL' -> mod EXPR-UNARY EXPR-MUL'
EXPR-UNARY -> EXPR-L0
EXPR-UNARY -> add EXPR-UNARY
EXPR-UNARY -> sub EXPR-UNARY
EXPR-L0 -> LITERAL
EXPR-L0 -> lparen EXPR rparen
EXPR-L0 -> symbol EXPR-SYM'
EXPR-SYM' ->
EXPR-SYM' -> INDEX-OP-INNER
EXPR-SYM' -> FUNCALL-ARGS
LITERAL -> string
LITERAL -> number
FOR-LOOP -> for symbol assign EXPR FOR-LOOP-TAIL
FOR-LOOP-TAIL -> to EXPR do PROCEDURAL-BLOCK
FOR-LOOP-TAIL -> downto EXPR do PROCEDURAL-BLOCK
WHILE-LOOP -> while EXPR do PROCEDURAL-BLOCK
ASSIGNMENT -> symbol ASSIGNMENT-RST
ASSIGNMENT-RST -> assign EXPR
ASSIGNMENT-RST -> INDEX-OP-INNER assign EXPR
IF-ELSE-BLOCK -> if EXPR then PROCEDURAL-BLOCK THEN-BRANCH&
THEN-BRANCH& ->
THEN-BRANCH& -> else PROCEDURAL-BLOCK
PROCEDURAL-BLOCK -> FOR-LOOP
PROCEDURAL-BLOCK -> WHILE-LOOP
PROCEDURAL-BLOCK -> IF-ELSE-BLOCK
PROCEDURAL-BLOCK -> FUNCALL-OR-ASSIGNMENT
PROCEDURAL-BLOCK -> BEGIN-END-BLOCK
PROCEDURAL-BLOCK -> exit
FUNCALL-OR-ASSIGNMENT -> symbol FUNCALL-OR-ASSIGNMENT-RST
FUNCALL-OR-ASSIGNMENT-RST -> ASSIGNMENT-RST
FUNCALL-OR-ASSIGNMENT-RST -> FUNCALL-ARGS
BEGIN-END-BLOCK -> begin PROCEDURAL-BLOCK BEGIN-END-BLOCK-RST end
BEGIN-END-BLOCK-RST ->
BEGIN-END-BLOCK-RST -> semicolon BEGIN-END-BLOCK-REC
BEGIN-END-BLOCK-REC ->
BEGIN-END-BLOCK-REC -> PROCEDURAL-BLOCK BEGIN-END-BLOCK-RST