-
Notifications
You must be signed in to change notification settings - Fork 1
/
BNF
119 lines (91 loc) · 3.12 KB
/
BNF
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
Lua 5.1 BNF in Lemon by RiciLake
* chunk ::= block .
* semi ::= ';' .
* semi ::= .
* block ::= scope statlist .
* block ::= scope statlist laststat semi .
* ublock ::= block 'until' exp .
* scope ::= .
* scope ::= scope statlist binding semi.
* statlist ::= .
* statlist ::= statlist stat semi .
* stat ::= 'do' block 'end' .
* stat ::= 'while' exp 'do' block 'end' .
* stat ::= repetition 'do' block 'end' .
* stat ::= 'repeat' ublock .
* stat ::= 'if' conds 'end' .
* stat ::= 'function' funcname funcbody .
* stat ::= setlist '=' explist1 .
* stat ::= functioncall .
* repetition ::= 'for' NAME '=' explist23 .
* repetition ::= 'for' namelist 'in' explist1 .
* conds ::= condlist .
* conds ::= condlist 'else' block .
* condlist ::= cond .
* condlist ::= condlist 'elseif' cond .
* cond ::= exp 'then' block .
* laststat ::= 'break' .
* laststat ::= 'return' .
* laststat ::= 'return' explist1 .
* binding ::= 'local' namelist .
* binding ::= 'local' namelist '=' explist1 .
* binding ::= 'local' 'function' NAME funcbody .
* funcname ::= dottedname .
* funcname ::= dottedname ':' NAME .
* dottedname ::= NAME .
* dottedname ::= dottedname '.' NAME .
* namelist ::= NAME .
* namelist ::= namelist ',' NAME .
* explist1 ::= exp .
* explist1 ::= explist1 ',' exp .
* explist23 ::= exp ',' exp .
* explist23 ::= exp ',' exp ',' exp .
%left 'or' .
%left 'and' .
%left '<' '<=' '>' '>=' '==' '~=' .
%right '..' .
%left '+' '-' .
%left '*' '/' '%' .
%right 'not' '#' .
%right '^' .
* exp ::= 'nil'|'true'|'false'|NUMBER|STRING|'...' .
* exp ::= function .
* exp ::= prefixexp .
* exp ::= tableconstructor .
* exp ::= 'not'|'#'|'-' exp . ['not']
* exp ::= exp 'or' exp .
* exp ::= exp 'and' exp .
* exp ::= exp '<'|'<='|'>'|'>='|'=='|'~=' exp .
* exp ::= exp '..' exp .
* exp ::= exp '+'|'-' exp .
* exp ::= exp '*'|'/'|'%' exp .
* exp ::= exp '^' exp .
* setlist ::= var .
* setlist ::= setlist ',' var .
* var ::= NAME .
* var ::= prefixexp '[' exp ']' .
* var ::= prefixexp '.' NAME .
* prefixexp ::= var .
* prefixexp ::= functioncall .
* prefixexp ::= OPEN exp ')' .
* functioncall ::= prefixexp args .
* functioncall ::= prefixexp ':' NAME args .
* args ::= '(' ')' .
* args ::= '(' explist1 ')' .
* args ::= tableconstructor .
* args ::= STRING .
* function ::= 'function' funcbody .
* funcbody ::= params block 'end' .
* params ::= '(' parlist ')' .
* parlist ::= .
* parlist ::= namelist .
* parlist ::= '...' .
* parlist ::= namelist ',' '...' .
* tableconstructor ::= '{' '}' .
* tableconstructor ::= '{' fieldlist '}' .
* tableconstructor ::= '{' fieldlist ','|';' '}' .
* fieldlist ::= field .
* fieldlist ::= fieldlist ','|';' field .
* field ::= exp .
* field ::= NAME '=' exp .
* field ::= '[' exp ']' '=' exp .