pymoca 0.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pymoca/Modelica.g4 +556 -0
- pymoca/__init__.py +3 -0
- pymoca/_version.py +683 -0
- pymoca/ast.py +910 -0
- pymoca/backends/__init__.py +0 -0
- pymoca/backends/casadi/__init__.py +0 -0
- pymoca/backends/casadi/_options.py +42 -0
- pymoca/backends/casadi/alias_relation.py +98 -0
- pymoca/backends/casadi/api.py +522 -0
- pymoca/backends/casadi/generator.py +1051 -0
- pymoca/backends/casadi/model.py +1465 -0
- pymoca/backends/casadi/mtensor.py +44 -0
- pymoca/backends/sympy/__init__.py +0 -0
- pymoca/backends/sympy/generator.py +218 -0
- pymoca/backends/sympy/runtime.py +167 -0
- pymoca/backends/xml/__init__.py +0 -0
- pymoca/backends/xml/analysis.py +38 -0
- pymoca/backends/xml/generator.py +134 -0
- pymoca/backends/xml/model.py +246 -0
- pymoca/backends/xml/parser.py +395 -0
- pymoca/backends/xml/sim_scipy.py +190 -0
- pymoca/generated/ModelicaLexer.py +7261 -0
- pymoca/generated/ModelicaListener.py +959 -0
- pymoca/generated/ModelicaParser.py +15653 -0
- pymoca/generated/ModelicaVisitor.py +488 -0
- pymoca/generated/__init__.py +0 -0
- pymoca/parser.py +1115 -0
- pymoca/tree.py +1271 -0
- pymoca-0.0.0.dist-info/LICENSE +28 -0
- pymoca-0.0.0.dist-info/METADATA +155 -0
- pymoca-0.0.0.dist-info/RECORD +33 -0
- pymoca-0.0.0.dist-info/WHEEL +5 -0
- pymoca-0.0.0.dist-info/top_level.txt +1 -0
pymoca/Modelica.g4
ADDED
|
@@ -0,0 +1,556 @@
|
|
|
1
|
+
grammar Modelica;
|
|
2
|
+
// TODO: Update to MLS 3.5 (this appears to be 3.3.0)
|
|
3
|
+
//=========================================================
|
|
4
|
+
// B.2.1 Stored Definition - Within
|
|
5
|
+
//=========================================================
|
|
6
|
+
|
|
7
|
+
// B.2.1.1 ------------------------------------------------
|
|
8
|
+
stored_definition :
|
|
9
|
+
(WITHIN component_reference? ';')?
|
|
10
|
+
(stored_definition_class)*
|
|
11
|
+
;
|
|
12
|
+
|
|
13
|
+
stored_definition_class :
|
|
14
|
+
FINAL? class_definition ';'
|
|
15
|
+
;
|
|
16
|
+
|
|
17
|
+
//=========================================================
|
|
18
|
+
// B.2.2 Class Definition
|
|
19
|
+
//=========================================================
|
|
20
|
+
|
|
21
|
+
// B.2.2.1 ------------------------------------------------
|
|
22
|
+
class_definition :
|
|
23
|
+
ENCAPSULATED? class_prefixes
|
|
24
|
+
class_specifier
|
|
25
|
+
;
|
|
26
|
+
|
|
27
|
+
// B.2.2.2 ------------------------------------------------
|
|
28
|
+
class_prefixes :
|
|
29
|
+
PARTIAL?
|
|
30
|
+
class_type
|
|
31
|
+
;
|
|
32
|
+
|
|
33
|
+
class_type:
|
|
34
|
+
'class'
|
|
35
|
+
| 'model'
|
|
36
|
+
| 'operator'? 'record'
|
|
37
|
+
| 'block'
|
|
38
|
+
| 'expandable'? 'connector'
|
|
39
|
+
| 'type'
|
|
40
|
+
| 'package'
|
|
41
|
+
| ('pure' | 'impure')? 'operator'? 'function'
|
|
42
|
+
| 'operator'
|
|
43
|
+
;
|
|
44
|
+
|
|
45
|
+
// B.2.2.3 ------------------------------------------------
|
|
46
|
+
class_specifier :
|
|
47
|
+
IDENT string_comment composition 'end' IDENT # class_spec_comp
|
|
48
|
+
| IDENT '=' base_prefix component_reference
|
|
49
|
+
class_modification? comment # class_spec_base
|
|
50
|
+
| IDENT '=' 'enumeration' '(' (enum_list? | ':') ')' comment # class_spec_enum
|
|
51
|
+
| IDENT '=' 'der' '(' name ',' IDENT (',' IDENT )* ')' comment # class_spec_der
|
|
52
|
+
| 'extends' IDENT class_modification? string_comment
|
|
53
|
+
composition 'end' IDENT # class_spec_extends
|
|
54
|
+
;
|
|
55
|
+
|
|
56
|
+
// B.2.2.4 ------------------------------------------------
|
|
57
|
+
base_prefix :
|
|
58
|
+
type_prefix
|
|
59
|
+
;
|
|
60
|
+
|
|
61
|
+
// B.2.2.5 ------------------------------------------------
|
|
62
|
+
enum_list :
|
|
63
|
+
enumeration_literal (',' enumeration_literal)*
|
|
64
|
+
;
|
|
65
|
+
|
|
66
|
+
// B.2.2.6 ------------------------------------------------
|
|
67
|
+
enumeration_literal :
|
|
68
|
+
IDENT comment
|
|
69
|
+
;
|
|
70
|
+
|
|
71
|
+
// B.2.2.7 ------------------------------------------------
|
|
72
|
+
composition :
|
|
73
|
+
epriv=element_list
|
|
74
|
+
(
|
|
75
|
+
'public' epub=element_list
|
|
76
|
+
| 'protected' epro=element_list
|
|
77
|
+
| equation_section
|
|
78
|
+
| algorithm_section
|
|
79
|
+
)*
|
|
80
|
+
( 'external' language_specification?
|
|
81
|
+
external_function_call?
|
|
82
|
+
ext_annotation=annotation? ';')?
|
|
83
|
+
(comp_annotation=annotation ';')?
|
|
84
|
+
;
|
|
85
|
+
|
|
86
|
+
// B.2.2.8 ------------------------------------------------
|
|
87
|
+
language_specification :
|
|
88
|
+
STRING
|
|
89
|
+
;
|
|
90
|
+
|
|
91
|
+
// B.2.2.9 ------------------------------------------------
|
|
92
|
+
external_function_call :
|
|
93
|
+
(component_reference '=')?
|
|
94
|
+
IDENT '(' expression_list? ')'
|
|
95
|
+
;
|
|
96
|
+
|
|
97
|
+
// B.2.2.10 ------------------------------------------------
|
|
98
|
+
element_list :
|
|
99
|
+
(element ';')*
|
|
100
|
+
;
|
|
101
|
+
|
|
102
|
+
// B.2.2.11 ------------------------------------------------
|
|
103
|
+
element :
|
|
104
|
+
import_clause
|
|
105
|
+
| extends_clause
|
|
106
|
+
| regular_element
|
|
107
|
+
| replaceable_element
|
|
108
|
+
;
|
|
109
|
+
|
|
110
|
+
regular_element:
|
|
111
|
+
REDECLARE? FINAL? INNER? OUTER?
|
|
112
|
+
(class_elem=class_definition | comp_elem=component_clause)
|
|
113
|
+
;
|
|
114
|
+
|
|
115
|
+
replaceable_element:
|
|
116
|
+
REDECLARE? FINAL? INNER? OUTER? 'replaceable'
|
|
117
|
+
(class_elem=class_definition | comp_elem=component_clause)
|
|
118
|
+
(constraining_clause comment)?
|
|
119
|
+
;
|
|
120
|
+
|
|
121
|
+
// B.2.2.12 ------------------------------------------------
|
|
122
|
+
import_clause :
|
|
123
|
+
'import' ( IDENT '=' component_reference
|
|
124
|
+
| component_reference ('.*' | '.{' import_list '}' )? ) comment
|
|
125
|
+
;
|
|
126
|
+
|
|
127
|
+
// B.2.2.13 ------------------------------------------------
|
|
128
|
+
import_list :
|
|
129
|
+
IDENT (',' import_list)*
|
|
130
|
+
;
|
|
131
|
+
|
|
132
|
+
//=========================================================
|
|
133
|
+
// B.2.3 Extends
|
|
134
|
+
//=========================================================
|
|
135
|
+
|
|
136
|
+
// B.2.3.1 ------------------------------------------------
|
|
137
|
+
extends_clause :
|
|
138
|
+
'extends' component_reference class_modification? annotation?
|
|
139
|
+
;
|
|
140
|
+
|
|
141
|
+
// B.2.3.2 ------------------------------------------------
|
|
142
|
+
constraining_clause:
|
|
143
|
+
'constrainedby' name class_modification?
|
|
144
|
+
;
|
|
145
|
+
|
|
146
|
+
//=========================================================
|
|
147
|
+
// B.2.4 Component Clause
|
|
148
|
+
//=========================================================
|
|
149
|
+
|
|
150
|
+
// B.2.4.1 ------------------------------------------------
|
|
151
|
+
component_clause :
|
|
152
|
+
type_prefix type_specifier array_subscripts? component_list
|
|
153
|
+
;
|
|
154
|
+
|
|
155
|
+
// B.2.4.2 ------------------------------------------------
|
|
156
|
+
type_prefix :
|
|
157
|
+
('flow' | 'stream')?
|
|
158
|
+
('discrete' | 'parameter' | 'constant')?
|
|
159
|
+
('input' | 'output')?
|
|
160
|
+
;
|
|
161
|
+
|
|
162
|
+
// B.2.4.3 ------------------------------------------------
|
|
163
|
+
type_specifier_element :
|
|
164
|
+
IDENT
|
|
165
|
+
;
|
|
166
|
+
|
|
167
|
+
type_specifier :
|
|
168
|
+
type_specifier_element ('.' type_specifier_element)*
|
|
169
|
+
;
|
|
170
|
+
|
|
171
|
+
// B.2.4.4 ------------------------------------------------
|
|
172
|
+
component_list:
|
|
173
|
+
component_declaration ( ',' component_declaration)*
|
|
174
|
+
;
|
|
175
|
+
|
|
176
|
+
// B.2.4.5 ------------------------------------------------
|
|
177
|
+
component_declaration :
|
|
178
|
+
declaration condition_attribute? comment
|
|
179
|
+
;
|
|
180
|
+
|
|
181
|
+
// B.2.4.6 ------------------------------------------------
|
|
182
|
+
condition_attribute :
|
|
183
|
+
'if' expression
|
|
184
|
+
;
|
|
185
|
+
|
|
186
|
+
// B.2.4.7 ------------------------------------------------
|
|
187
|
+
declaration :
|
|
188
|
+
IDENT array_subscripts? modification?
|
|
189
|
+
;
|
|
190
|
+
|
|
191
|
+
//=========================================================
|
|
192
|
+
// B.2.5 Modification
|
|
193
|
+
//=========================================================
|
|
194
|
+
|
|
195
|
+
// B.2.5.1 ------------------------------------------------
|
|
196
|
+
modification :
|
|
197
|
+
class_modification ('=' expression)? # modification_class
|
|
198
|
+
| '=' expression # modification_assignment
|
|
199
|
+
| ':=' expression # modification_assignment2
|
|
200
|
+
;
|
|
201
|
+
|
|
202
|
+
// B.2.5.2 ------------------------------------------------
|
|
203
|
+
class_modification :
|
|
204
|
+
'(' argument_list? ')'
|
|
205
|
+
;
|
|
206
|
+
|
|
207
|
+
// B.2.5.3 ------------------------------------------------
|
|
208
|
+
argument_list :
|
|
209
|
+
argument (',' argument)*
|
|
210
|
+
;
|
|
211
|
+
|
|
212
|
+
// B.2.5.4 ------------------------------------------------
|
|
213
|
+
argument :
|
|
214
|
+
element_modification_or_replaceable
|
|
215
|
+
| element_redeclaration
|
|
216
|
+
;
|
|
217
|
+
|
|
218
|
+
// B.2.5.5 ------------------------------------------------
|
|
219
|
+
element_modification_or_replaceable:
|
|
220
|
+
EACH? FINAL?
|
|
221
|
+
(element_modification | element_replaceable)
|
|
222
|
+
;
|
|
223
|
+
|
|
224
|
+
// B.2.5.6 ------------------------------------------------
|
|
225
|
+
element_modification :
|
|
226
|
+
component_reference modification? string_comment
|
|
227
|
+
;
|
|
228
|
+
|
|
229
|
+
// B.2.5.7 ------------------------------------------------
|
|
230
|
+
element_redeclaration :
|
|
231
|
+
REDECLARE EACH? FINAL?
|
|
232
|
+
( (short_class_definition | component_clause1)
|
|
233
|
+
| element_replaceable)
|
|
234
|
+
;
|
|
235
|
+
|
|
236
|
+
// B.2.5.8 ------------------------------------------------
|
|
237
|
+
element_replaceable :
|
|
238
|
+
'replaceable'
|
|
239
|
+
(short_class_definition | component_clause1)
|
|
240
|
+
constraining_clause?
|
|
241
|
+
;
|
|
242
|
+
|
|
243
|
+
// B.2.5.9 ------------------------------------------------
|
|
244
|
+
component_clause1 :
|
|
245
|
+
type_prefix type_specifier component_declaration1
|
|
246
|
+
;
|
|
247
|
+
|
|
248
|
+
// B.2.5.10 ------------------------------------------------
|
|
249
|
+
component_declaration1 :
|
|
250
|
+
declaration comment
|
|
251
|
+
;
|
|
252
|
+
|
|
253
|
+
// B.2.5.11 ------------------------------------------------
|
|
254
|
+
short_class_definition :
|
|
255
|
+
class_prefixes IDENT '='
|
|
256
|
+
( base_prefix component_reference array_subscripts?
|
|
257
|
+
class_modification? comment
|
|
258
|
+
| 'enumeration' '(' (enum_list? | ':') ')' comment)
|
|
259
|
+
;
|
|
260
|
+
|
|
261
|
+
//=========================================================
|
|
262
|
+
// B.2.6 Equations
|
|
263
|
+
//=========================================================
|
|
264
|
+
|
|
265
|
+
// B.2.6.1 ------------------------------------------------
|
|
266
|
+
equation_block :
|
|
267
|
+
(equation ';')*
|
|
268
|
+
;
|
|
269
|
+
|
|
270
|
+
equation_section :
|
|
271
|
+
INITIAL? 'equation' equation_block
|
|
272
|
+
;
|
|
273
|
+
|
|
274
|
+
// B.2.6.2 ------------------------------------------------
|
|
275
|
+
statement_block :
|
|
276
|
+
(statement ';')*
|
|
277
|
+
;
|
|
278
|
+
|
|
279
|
+
algorithm_section :
|
|
280
|
+
INITIAL? 'algorithm' statement_block
|
|
281
|
+
;
|
|
282
|
+
|
|
283
|
+
// B.2.6.3 ------------------------------------------------
|
|
284
|
+
equation_options :
|
|
285
|
+
simple_expression '=' expression # equation_simple
|
|
286
|
+
| if_equation # equation_if
|
|
287
|
+
| for_equation # equation_for
|
|
288
|
+
| connect_clause # equation_connect_clause
|
|
289
|
+
| when_equation # equation_when
|
|
290
|
+
| name function_call_args # equation_function
|
|
291
|
+
;
|
|
292
|
+
|
|
293
|
+
// B.2.6.4 ------------------------------------------------
|
|
294
|
+
equation :
|
|
295
|
+
equation_options
|
|
296
|
+
comment
|
|
297
|
+
;
|
|
298
|
+
|
|
299
|
+
// B.2.6.5 ------------------------------------------------
|
|
300
|
+
statement_options :
|
|
301
|
+
component_reference (':=' expression | function_call_args) # statement_component_reference
|
|
302
|
+
| '(' component_reference (',' component_reference)* ')' ':='
|
|
303
|
+
component_reference function_call_args # statement_component_function
|
|
304
|
+
| 'break' # statement_break
|
|
305
|
+
| 'return' # statement_return
|
|
306
|
+
| if_statement # statement_if
|
|
307
|
+
| for_statement # statement_for
|
|
308
|
+
| while_statement # statement_while
|
|
309
|
+
| when_statement # statement_when
|
|
310
|
+
;
|
|
311
|
+
|
|
312
|
+
// B.2.6.6 ------------------------------------------------
|
|
313
|
+
statement :
|
|
314
|
+
statement_options
|
|
315
|
+
comment
|
|
316
|
+
;
|
|
317
|
+
|
|
318
|
+
// B.2.6.7 ------------------------------------------------
|
|
319
|
+
if_equation :
|
|
320
|
+
'if' conditions+=expression 'then'
|
|
321
|
+
blocks+=equation_block
|
|
322
|
+
('elseif' conditions+=expression 'then'
|
|
323
|
+
blocks+=equation_block
|
|
324
|
+
)*
|
|
325
|
+
('else'
|
|
326
|
+
blocks+=equation_block
|
|
327
|
+
)?
|
|
328
|
+
'end' 'if'
|
|
329
|
+
;
|
|
330
|
+
|
|
331
|
+
// B.2.6.8 ------------------------------------------------
|
|
332
|
+
if_statement :
|
|
333
|
+
'if' conditions+=expression 'then'
|
|
334
|
+
blocks+=statement_block
|
|
335
|
+
('elseif' conditions+=expression 'then'
|
|
336
|
+
blocks+=statement_block
|
|
337
|
+
)*
|
|
338
|
+
('else'
|
|
339
|
+
blocks+=statement_block
|
|
340
|
+
)?
|
|
341
|
+
'end' 'if'
|
|
342
|
+
;
|
|
343
|
+
|
|
344
|
+
// B.2.6.9 ------------------------------------------------
|
|
345
|
+
for_equation :
|
|
346
|
+
'for' indices=for_indices 'loop'
|
|
347
|
+
block=equation_block
|
|
348
|
+
'end' 'for'
|
|
349
|
+
;
|
|
350
|
+
|
|
351
|
+
// B.2.6.10 ------------------------------------------------
|
|
352
|
+
for_statement :
|
|
353
|
+
'for' indices=for_indices 'loop'
|
|
354
|
+
block=statement_block
|
|
355
|
+
'end' 'for'
|
|
356
|
+
;
|
|
357
|
+
|
|
358
|
+
// B.2.6.11 ------------------------------------------------
|
|
359
|
+
for_indices :
|
|
360
|
+
for_index (',' for_index)*
|
|
361
|
+
;
|
|
362
|
+
|
|
363
|
+
// B.2.6.12 ------------------------------------------------
|
|
364
|
+
for_index :
|
|
365
|
+
IDENT ('in' expression)?
|
|
366
|
+
;
|
|
367
|
+
|
|
368
|
+
// B.2.6.13 ------------------------------------------------
|
|
369
|
+
while_statement:
|
|
370
|
+
'while' condition=expression 'loop'
|
|
371
|
+
block=statement_block
|
|
372
|
+
'end' 'while'
|
|
373
|
+
;
|
|
374
|
+
|
|
375
|
+
// B.2.6.14 ------------------------------------------------
|
|
376
|
+
when_equation:
|
|
377
|
+
'when' conditions+=expression 'then'
|
|
378
|
+
blocks+=equation_block
|
|
379
|
+
('elsewhen' conditions+=expression 'then'
|
|
380
|
+
blocks+=equation_block
|
|
381
|
+
)*
|
|
382
|
+
'end' 'when'
|
|
383
|
+
;
|
|
384
|
+
|
|
385
|
+
// B.2.6.15 ------------------------------------------------
|
|
386
|
+
when_statement:
|
|
387
|
+
'when' conditions+=expression 'then'
|
|
388
|
+
blocks+=statement_block
|
|
389
|
+
('elsewhen' conditions+=expression 'then'
|
|
390
|
+
blocks+=statement_block
|
|
391
|
+
)*
|
|
392
|
+
'end' 'when'
|
|
393
|
+
;
|
|
394
|
+
|
|
395
|
+
// B.2.6.16 ------------------------------------------------
|
|
396
|
+
connect_clause :
|
|
397
|
+
'connect' '(' component_reference ',' component_reference ')'
|
|
398
|
+
;
|
|
399
|
+
|
|
400
|
+
//=========================================================
|
|
401
|
+
// B.2.7 Expressions
|
|
402
|
+
//=========================================================
|
|
403
|
+
|
|
404
|
+
// B.2.7.1 ------------------------------------------------
|
|
405
|
+
// TODO: What is the difference between expression and simple_expression?
|
|
406
|
+
// Can't we get rid of one of them?
|
|
407
|
+
expression :
|
|
408
|
+
simple_expression # expression_simple
|
|
409
|
+
| 'if' conditions+=expression 'then' blocks+=expression
|
|
410
|
+
( 'elseif' conditions+=expression 'then' blocks+=expression)*
|
|
411
|
+
'else' blocks+=expression # expression_if
|
|
412
|
+
;
|
|
413
|
+
|
|
414
|
+
// B.2.7.2 ------------------------------------------------
|
|
415
|
+
simple_expression :
|
|
416
|
+
expr (':' expr
|
|
417
|
+
(':' expr)?)?
|
|
418
|
+
;
|
|
419
|
+
|
|
420
|
+
// B.2.7.3 ------------------------------------------------
|
|
421
|
+
expr :
|
|
422
|
+
op=('+' | '-') expr # expr_signed
|
|
423
|
+
| primary op=('^' | '.^') primary # expr_exp
|
|
424
|
+
| expr op=('*' | '/' | '.*' | './') expr # expr_mul
|
|
425
|
+
| expr op=('+' | '-' | '.+' | '.-') expr # expr_add
|
|
426
|
+
| expr op=('<' | '<=' | '>' | '>=' | '==' | '<>') expr # expr_rel
|
|
427
|
+
| 'not' expr # expr_not
|
|
428
|
+
| expr 'and' expr # expr_and
|
|
429
|
+
| expr 'or' expr # expr_or
|
|
430
|
+
| primary # expr_primary
|
|
431
|
+
;
|
|
432
|
+
|
|
433
|
+
// B.2.7.4 ------------------------------------------------
|
|
434
|
+
// TODO: Figure out what an output_expression_list is (i.e. find an example).
|
|
435
|
+
primary :
|
|
436
|
+
UNSIGNED_NUMBER # primary_unsigned_number
|
|
437
|
+
| STRING # primary_string
|
|
438
|
+
| 'false' # primary_false
|
|
439
|
+
| 'true' # primary_true
|
|
440
|
+
| component_reference function_call_args # primary_function
|
|
441
|
+
| 'der' function_call_args # primary_derivative
|
|
442
|
+
| 'initial' function_call_args # primary_initial
|
|
443
|
+
| component_reference # primary_component_reference
|
|
444
|
+
| '(' output_expression_list ')' # primary_output_expression_list
|
|
445
|
+
| '[' expression_list (';' expression_list)* ']' # primary_expression_list
|
|
446
|
+
| '{' function_arguments '}' # primary_function_arguments
|
|
447
|
+
| 'end' # primary_end
|
|
448
|
+
;
|
|
449
|
+
|
|
450
|
+
// B.2.7.5 ------------------------------------------------
|
|
451
|
+
name :
|
|
452
|
+
'.'? IDENT ('.' IDENT)*
|
|
453
|
+
;
|
|
454
|
+
|
|
455
|
+
// B.2.7.6 ------------------------------------------------
|
|
456
|
+
component_reference_element :
|
|
457
|
+
IDENT array_subscripts?
|
|
458
|
+
;
|
|
459
|
+
|
|
460
|
+
component_reference :
|
|
461
|
+
component_reference_element ('.' component_reference_element)*
|
|
462
|
+
;
|
|
463
|
+
|
|
464
|
+
// B.2.7.7 ------------------------------------------------
|
|
465
|
+
function_call_args :
|
|
466
|
+
'(' function_arguments? ')'
|
|
467
|
+
;
|
|
468
|
+
|
|
469
|
+
// B.2.7.8 ------------------------------------------------
|
|
470
|
+
function_arguments :
|
|
471
|
+
function_argument (',' function_argument | 'for' for_indices)*
|
|
472
|
+
| named_arguments
|
|
473
|
+
;
|
|
474
|
+
|
|
475
|
+
// B.2.7.9 ------------------------------------------------
|
|
476
|
+
named_arguments : named_argument (',' named_argument)*
|
|
477
|
+
;
|
|
478
|
+
|
|
479
|
+
// B.2.7.10 ------------------------------------------------
|
|
480
|
+
named_argument : IDENT '=' function_argument
|
|
481
|
+
;
|
|
482
|
+
|
|
483
|
+
// B.2.7.11 ------------------------------------------------
|
|
484
|
+
function_argument :
|
|
485
|
+
'function' name '(' named_arguments? ')' # argument_function
|
|
486
|
+
| expression # argument_expression
|
|
487
|
+
;
|
|
488
|
+
|
|
489
|
+
// B.2.7.12 ------------------------------------------------
|
|
490
|
+
output_expression_list :
|
|
491
|
+
expression? (',' expression)*
|
|
492
|
+
;
|
|
493
|
+
|
|
494
|
+
// B.2.7.13 ------------------------------------------------
|
|
495
|
+
expression_list :
|
|
496
|
+
expression (',' expression)*
|
|
497
|
+
;
|
|
498
|
+
|
|
499
|
+
// B.2.7.14 ------------------------------------------------
|
|
500
|
+
array_subscripts :
|
|
501
|
+
'[' subscript (',' subscript)* ']'
|
|
502
|
+
;
|
|
503
|
+
|
|
504
|
+
// B.2.7.15 ------------------------------------------------
|
|
505
|
+
subscript :
|
|
506
|
+
':' | expression
|
|
507
|
+
;
|
|
508
|
+
|
|
509
|
+
// B.2.7.16 ------------------------------------------------
|
|
510
|
+
comment :
|
|
511
|
+
string_comment annotation?
|
|
512
|
+
;
|
|
513
|
+
|
|
514
|
+
// B.2.7.17 ------------------------------------------------
|
|
515
|
+
string_comment :
|
|
516
|
+
(STRING ('+' STRING)*)?
|
|
517
|
+
;
|
|
518
|
+
|
|
519
|
+
// B.2.7.18 ------------------------------------------------
|
|
520
|
+
annotation :
|
|
521
|
+
'annotation' class_modification
|
|
522
|
+
;
|
|
523
|
+
|
|
524
|
+
//=========================================================
|
|
525
|
+
// Keywords
|
|
526
|
+
//=========================================================
|
|
527
|
+
EACH : 'each';
|
|
528
|
+
PARTIAL : 'partial';
|
|
529
|
+
FINAL : 'final';
|
|
530
|
+
WITHIN : 'within';
|
|
531
|
+
ENCAPSULATED : 'encapsulated';
|
|
532
|
+
REDECLARE : 'redeclare';
|
|
533
|
+
INNER : 'inner';
|
|
534
|
+
OUTER : 'outer';
|
|
535
|
+
INITIAL : 'initial';
|
|
536
|
+
IDENT : NONDIGIT ( DIGIT | NONDIGIT )* | Q_IDENT;
|
|
537
|
+
STRING : '"' ('\\"' | ~('"'))* '"';
|
|
538
|
+
//STRING : '"' (S_CHAR | S_ESCAPE | ' ')* '"';
|
|
539
|
+
UNSIGNED_NUMBER : UNSIGNED_INTEGER ( '.' UNSIGNED_NUMBER? )* ( [eE] [+-]? UNSIGNED_INTEGER)?;
|
|
540
|
+
COMMENT :
|
|
541
|
+
('/' '/' .*? '\n' | '/*' .*? '*/') -> channel(HIDDEN)
|
|
542
|
+
;
|
|
543
|
+
WS : [ \r\n\t]+ -> skip ; // toss out whitespace
|
|
544
|
+
|
|
545
|
+
//=========================================================
|
|
546
|
+
// Fragments
|
|
547
|
+
//=========================================================
|
|
548
|
+
fragment Q_IDENT : '\'' ( Q_CHAR | S_ESCAPE)+;
|
|
549
|
+
fragment NONDIGIT : [_a-zA-Z];
|
|
550
|
+
fragment S_CHAR : [\u0000-\u00FF];
|
|
551
|
+
fragment Q_CHAR : NONDIGIT | DIGIT | [!#$%&()*+,-./:;<>=?@[\]^{}| ];
|
|
552
|
+
fragment S_ESCAPE : ('\\\'' | '\\"' | '\\\\' | '\\?' | '\\b' |
|
|
553
|
+
'\\f' | '\\n' | '\\r' | '\\t' | '\\v' | '\\a');
|
|
554
|
+
fragment DIGIT : [0-9];
|
|
555
|
+
fragment UNSIGNED_INTEGER : DIGIT+;
|
|
556
|
+
// vi:ts=4:sw=4:expandtab:
|
pymoca/__init__.py
ADDED