-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGRAMMAR
More file actions
65 lines (39 loc) · 2.26 KB
/
Copy pathGRAMMAR
File metadata and controls
65 lines (39 loc) · 2.26 KB
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
<program> = <statement-list>
<array-row> = [ <expression> { [","] <expression> } [";"] ]
<array-matrix> = "[" { <array-row> } "]"
<param-list> = <expression> { "," <expression> }
<primary_expression> = "ID"
| "NUMBER"
| "STRING"
| ":"
| "end"
| <array-matrix>
| "(" expression ")"
<postfix-expression> = <primary-expression> [ ( "(" [ <param-list> ] ")" ) | " ]
<unary-expression> = { ( "-" | "+" ) } <postfix-expression>
<power-expression> = <unary-expression> { ("^" | ".^") <unary-expression> }
<multiplicative-expression> = <power-expression> { ("+" | "-" | ".*" | "./") <power-expression>}
<additive-expression> = <multiplicative-expression> { ("+" | "-") <multiplicative_expression>}
<relational-expression> = <additive-expression> { ("<" | "<=" |">" | ">=") <additive-expression> }
<equality-expression> = <relational-expression> { ("==" | "~=") <relational-expression> }
<and-expression> = <equality-expression> { "&&" <equality-expression> }
<or-expression> = <and-expression> { "||" <and-expression> }
<range-expression> = <or-expression> { ":" <or-expression> } ":" <or-expression>
<assginment-expression> = <range-expression> "=" <range-expression>
<selection-expression> = "(" <range-expression> ")"
<switch-statement> = "switch" ["("] <selection-expr> [")"] { "case" <selection-expr> <statement-list> } [ "otherwise" <statement-list> ] "end"
<if-statement> = "if" ["("] <range-expression> [")"] <statement-list> { "elseif" <statement-list> } [ "else" <statement-list> ] "end"
<jump-statement> = "break" | "continue" | "return"
<for-statement> = "for" ["("] "ID" "=" <range-expression> [")"] <statement-list> "end"
<while-statement> = "while" ["("] <range-expression> [")"] <statement-list> "end"
<function-declaration> = "function" [ <primary-expression> "=" ] "ID" "(" <param-list> ")" <statement-list> "end"
<expression-terminator> = (";" | "," | "\n" | "EOF")
<statement-expression> =
( <assignment-expression>
| <if-statement>
| <switch-statement>
| <while-statement>
| <for-statement>
| <function-declaration>
| <jump-declaration> ) [ <expression-terminator> ]
<statement-list> = { <statement-expression> }