-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
93 lines (76 loc) · 2.74 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
program -> definitions .
definitions -> definition definitions_rest .
definitions_rest -> definitions .
definitions_rest -> .
definition -> fun_definition .
definition -> var_definition .
fun_definition -> fun identifier "(" parameters ")" fun_definition_rest .
fun_definition_rest -> "=" statements .
fun_definition_rest -> .
parameters -> identifier parameters_rest .
parameters_rest -> "," parameters .
parameters_rest -> .
var_definition -> var identifier "=" initializers .
initializers -> initializer initializers_rest .
initializers_rest -> "," initializers .
initializers_rest -> .
initializer -> int_const initializer_rest .
initializer -> char_const .
initializer -> string_const .
initializer_rest -> "*" const .
initializer_rest -> .
const -> int_const | char_const | string_const .
statements -> statement statements_rest .
statements_rest -> "," statements .
statements_rest -> .
statement -> expression_or_assignment | if_statement | while_statement | let_statement .
if_statement -> "if" expression "then" statements optional_else "end" .
optional_else -> "else" statements .
optional_else -> .
while_statement -> "while" expression "do" statements "end" .
let_statement -> "let" definitions "in" statements "end" .
expression_or_assignment -> expression optional_assignment .
optional_assignment -> "=" expression .
optional_assignment -> .
expression -> disjunction .
disjunction -> conjunction disjunction_1 .
disjunction_1 -> "||" conjunction disjunction_1 .
disjunction_1 -> .
conjunction -> comparison conjunction_1 .
conjunction_1 -> "&&" comparison conjunction_1 .
conjunction_1 -> .
comparison -> addition comparison_1 .
comparison_1 -> "==" addition .
comparison_1 -> "!=" addition .
comparison_1 -> "<" addition .
comparison_1 -> ">" addition .
comparison_1 -> "<=" addition .
comparison_1 -> ">=" addition .
comparison_1 -> .
addition -> multiplication addition_1 .
addition_1 -> "+" multiplication addition_1 .
addition_1 -> "-" multiplication addition_1 .
addition_1 -> .
multiplication -> prefix multiplication_1.
multiplication_1 -> "*" prefix multiplication_1 .
multiplication_1 -> "/" prefix multiplication_1 .
multiplication_1 -> "%" prefix multiplication_1 .
multiplication_1 -> .
prefix -> "!" prefix .
prefix -> "+" prefix .
prefix -> "-" prefix .
prefix -> "^" prefix .
prefix -> postfix.
postfix -> const_or_grouping postfix_1 .
postfix_1 -> "^" .
postfix_1 -> .
const_or_grouping -> "(" expression ")" .
const_or_grouping -> const .
const_or_grouping -> function_call_or_variable_access .
function_call_or_variable_access -> identifier optional_function_call .
optional_function_call -> "(" arguments ")" .
optional_function_call -> .
arguments -> expression arguments_1 .
arguments -> .
arguments_1 -> "," expression arguments_1 .
arguments_1 -> .