summaryrefslogtreecommitdiffstats
path: root/rapcad.bnf
blob: dff4c2ce5dec78e0c311c56bff47a5d20abe44b6 (plain)
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<input> ::=
	<empty>
	| <use_declaration> <input>
	| <import_declaration> <input>
	| <single_declaration_list>
	| <codedoc> <input>

<codedoc> ::=
	"/**" <codedoc_param> "*/"

<codedoc_param> ::=
	<empty>
	| <doctext> <codedoc_param>
	| "@" <doctext> <codedoc_param>

<use_declaration> ::=
	"use"
	| "use" "as" <identifier> ';'

<import_declaration> ::=
	"import" "as" <identifier> ';'
	| "import" "as" <identifier> '(' <parameters> ')' ';'


<single_declaration_list> ::=
	<single_declaration>
	| <single_declaration_list> <single_declaration>

<declaration_list> ::=
	<declaration>
	| <declaration_list> <declaration>

<compound_declaration> ::=
	'{' '}'
	| '{' <declaration_list> '}'

<single_declaration> ::=
	<single_statement>
	| <define_declaration>

<declaration> ::=
	<statement>
	| <define_declaration>

<define_declaration> ::=
	"module" <identifier> '(' <parameters> ')' <module_scope>
	| "function" <identifier> '(' <parameters> ')' <function_scope>

<module_scope> ::=
	<compound_declaration>
	| <module_instance>

<function_scope> ::=
	'=' <expression> ';'
	| <compound_statement>

<statement> ::=
	<single_statement>
	| <compound_statement>

<single_statement> ::=
	<module_instance>
	| <assign_statement> ';'
	| <ifelse_statement>
	| <for_statement>
	| <return_statement>

<return_statement> ::=
	"return" <expression> ';'

<compound_statement> ::=
	'{' '}'
	| '{' <statement_list> '}'

<statement_list> ::=
	<statement>
	| <statement_list> <statement>

<assign_statement> ::=
	<variable> '=' <expression>
	| <variable> "~=" <expression>
	| <variable> "++"
	| <variable> "--"
	| <variable> "+=" <expression>
	| <variable> "-=" <expression>
	| "const" <identifier> '=' <expression>
	| "param" <identifier> '=' <expression>

<ifelse_statement> ::=
	"if" '(' <expression> ')' <statement>
	| "if" '(' <expression> ')' <statement> "else" <statement>

<for_statement> ::=
	"for" '(' <arguments> ')' <statement>

<variable> ::=
	<identifier>
	| '$' <identifier>

<expression> ::=
	"true"
	| "false"
	| "undef"
	| <variable>
	| <expression> '.' <identifier>
	| <string>
	| <number>
	| '[' <expression> ':' <expression> ']'
	| '[' <expression> ':' <expression> ':' <expression> ']'
	| '[' <vector_expression> <optional_commas> ']'
	| <expression> '^' <expression>
	| <expression> '*' <expression>
	| <expression> '~' <expression>
	| <expression> ".*" <expression>
	| <expression> '/' <expression>
	| <expression> "./" <expression>
	| <expression> "**" <expression>
	| <expression> '%' <expression>
	| <expression> '+' <expression>
	| <expression> '-' <expression>
	| <expression> '<' <expression>
	| <expression> "<=" <expression>
	| <expression> "==" <expression>
	| <expression> "!=" <expression>
	| <expression> ">=" <expression>
	| <expression> '>' <expression>
	| <expression> "&&" <expression>
	| <expression> "||" <expression>
	| <expression> "++"
	| <expression> "--"
	| '+' <expression>
	| '-' <expression>
	| '!' <expression>
	| '(' <expression> ')'
	| <expression> '?' <expression> ':' <expression>
	| <expression> '[' <expression> ']'
	| <invocation>

<invocation> ::=
	<identifier> "::" <invocation>
	| <identifier> '(' <arguments> ')'

<vector_expression> ::=
	<empty>
	| <expression>
	| <vector_expression> ',' <optional_commas> <expression>

<parameters> ::=
	<empty>
	| <parameter>
	| <parameters> ',' <parameter>

<parameter> ::=
	<identifier>
	| <identifier> '=' <expression>

<compound_instance> ::=
	<compound_statement>
	| <ifelse_statement>
	| <for_statement>
	| <module_instance>

<module_instance> ::=
	<single_instance> ';'
	| <single_instance> <compound_instance>

<single_instance> ::=
	<identifier> "::" <single_instance>
	| <identifier> '(' <arguments> ')'
	| '!' <single_instance>
	| '#' <single_instance>
	| '%' <single_instance>
	| '*' <single_instance>

<arguments> ::=
	<empty>
	| <argument>
	| <arguments> ',' <optional_commas> <argument>

<optional_commas> ::=
	<empty>
	| ',' <optional_commas>

<argument> ::=
	<expression>
	| <variable> '=' <expression>