-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathsyntax_5.1.txt
107 lines (85 loc) · 1.64 KB
/
syntax_5.1.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
chunk ::= {stat [';']} [laststat [';']] ;
block ::= chunk ;
stat ::= varlist '=' explist
| functioncall
| 'do' block 'end'
| 'while' exp 'do' block 'end'
| 'repeat' block 'until' exp
| 'if' exp 'then' block {'elseif' exp 'then' block} ['else' block] 'end'
| 'for' Name '=' exp ',' exp [',' exp] 'do' block 'end'
| 'for' namelist 'in' explist 'do' block 'end'
| 'function' funcname funcbody
| 'local' 'function' Name funcbody
| 'local' namelist ['=' explist]
;
laststat ::= 'return' [explist]
| 'break'
;
funcname ::= Name {'.' Name} [':' Name] ;
varlist ::= var {',' var} ;
var ::= Name
| prefixexp '[' exp ']'
| prefixexp '.' Name
;
namelist ::= Name {',' Name} ;
explist ::= {exp ','} exp ;
exp ::= 'nil'
| 'false'
| 'true'
| Numeral
| LiteralString
| '...'
| functiondef
| prefixexp
| tableconstructor
| exp binop exp
| unop exp
;
prefixexp ::= var
| functioncall
| '(' exp ')'
;
functioncall ::= prefixexp args
| prefixexp ':' Name args
;
args ::= '(' [explist] ')'
| tableconstructor
| LiteralString
;
functiondef ::= 'function' funcbody ;
funcbody ::= '(' [parlist] ')' block 'end' ;
parlist ::= namelist [',' '...']
| '...'
;
tableconstructor ::= '{' [fieldlist] '}' ;
fieldlist ::= field {fieldsep field} [fieldsep] ;
field ::= '[' exp ']' '=' exp
| Name '=' exp
| exp
;
fieldsep ::= ','
| ';'
;
binop ::= '+'
| '-'
| '*'
| '/'
| '^'
| '%'
| '..'
| '<'
| '<='
| '>'
| '>='
| '=='
| '~='
| 'and'
| 'or'
;
unop ::= '-'
| 'not'
| '#'
;
-- Name ::= ... how to define valid names ...
-- Numeral ::= ... how to define numerals ...
-- LiteralString ::= how to define literal strings ...