/
textuml.scc
executable file
·911 lines (607 loc) · 29.3 KB
/
textuml.scc
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
Package com.abstratt.mdd.frontend.textuml.grammar;
Helpers
unicode_input_character = [0..0xffff];
ht = 0x0009;
lf = 0x000a;
ff = 0x000c;
cr = 0x000d;
sp = ' ';
line_terminator = lf | cr | cr lf;
input_character = [unicode_input_character - [cr + lf]];
escape_character = '\';
not_star = [input_character - '*'] | line_terminator;
not_star_not_slash = [input_character - ['*' + '/']] | line_terminator;
not_star_not_rbracket = [input_character - ['*' + ')']] | line_terminator;
ascii_char = [0..255] ;
symbols = [0x20..0x2F] | [0x3A..0x40] | 0x5B | [0x5D..0x5E] | 0x60 | [0x7B..0x7E] ;
//- '+' - '.' - '(' - ')' - '[' - ']' - '{' - '}'
unicode_input_character_minus_symbols = [[[[[[unicode_input_character - [0x20..0x2F]] - [0x3A..0x40]] - 0x5B] - [0x5D..0x5E]] - 0x60] - [0x7B..0x7E]];
digit = ['0' .. '9'] ;
identifier_first_character = [[unicode_input_character_minus_symbols - [cr + lf]] - digit];
identifier_following_character = [unicode_input_character_minus_symbols - [cr + lf]];
// un-printable characters
// tab = 9 ;
// cr = 13 ;
// lf = 10 ;
// blank = ' ' ;
single_quote = ''' ;
quote = '"';
underscore = '_';
plus = '+' ;
minus = '-' ;
mult = '*' ;
div = '/';
assignop = ':=' ;
exclamation = '!' ;
// relational symbols
equals = '=';
not_equals = exclamation '=';
same_helper = '=' '=';
not_same_helper = exclamation '=' '=';
xxx = exclamation '=' '=';
lab = '<' ;
lab_equals = '<' '=' ;
rab = '>' ;
rab_equals = '>' '=' ;
// separator symbols
comma = ',' ;
colon = ':' ;
semicolon = ';' ;
namespace_separator = '::' ;
hash = '#' ;
l_paren = '(' ;
r_paren = ')' ;
l_bracket = '[';
r_bracket = ']';
l_curly_bracket = '{' ;
r_curly_bracket = '}' ;
right_arrow = '-' '>';
left_arrow = '<' '-';
l_guillemot = '«' ;
r_guillemot = '»' ;
Tokens
// reserved words
abstract = 'abstract' ;
access = 'access' ;
actor = 'actor' ;
aggregation = 'aggregation' ;
alias = 'alias' ;
allow = 'allow' ;
all = 'all' ;
and = 'and' ;
any = 'any';
anyone = 'anyone';
apply = 'apply';
association = 'association' ;
as = 'as' ;
attribute = 'attribute' ;
begin = 'begin' ;
broadcast = 'broadcast' ;
by = 'by' ;
call = 'call';
catch = 'catch' ;
clazz = 'class' ;
component = 'component' ;
composition = 'composition' ;
connector = 'connector';
constructor = 'constructor';
create = 'create';
datatype = 'datatype' ;
delete = 'delete';
dependency = 'dependency' ;
derived = 'derived' ;
destroy = 'destroy' ;
do = 'do' ;
else = 'else' ;
elseif = 'elseif' ;
end = 'end' ;
entry = 'entry' ;
enumeration = 'enumeration' ;
exit = 'exit' ;
extends = 'extends' ;
extent = 'extent' ;
external = 'external' ;
false = 'false';
final = 'final';
finally = 'finally';
function = 'function' ;
id = 'id' ;
if = 'if' ;
implements = 'implements' ;
import = 'import' ;
in = 'in' ;
initial = 'initial' ;
inout = 'inout' ;
interface = 'interface' ;
invariant = 'invariant' ;
is = 'is' ;
link = 'link' ;
enumeration_literal = 'literal' ;
load = 'load' ;
model = 'model' ;
navigable = 'navigable' ;
new = 'new' ;
none = 'none' ;
nonunique = 'nonunique';
not = 'not' | exclamation;
null = 'null' ;
on = 'on' ;
operation = 'operation' ;
opposite = 'opposite' ;
or = 'or' ;
ordered = 'ordered' ;
out = 'out' ;
package = 'package' ;
parameterset = 'parameterset' ;
port = 'port' ;
postcondition = 'postcondition' ;
precondition = 'precondition' ;
primitive = 'primitive' ;
private = 'private' ;
profile = 'profile' ;
property = 'property' ;
protected = 'protected' ;
provided = 'provided' ;
public = 'public' ;
query = 'query' ;
raise = 'raise' ;
raises = 'raises' ;
read = 'read';
readonly = 'readonly' ;
reception = 'reception' ;
reference = 'reference' ;
repeat = 'repeat' ;
required = 'required' ;
return = 'return' ;
role = 'role' ;
self = 'self' ;
send = 'send' ;
signal = 'signal';
specializes = 'specializes' ;
state = 'state' ;
statemachine = 'statemachine' ;
static = 'static' ;
stereotype = 'stereotype' ;
subsets = 'subsets' ;
terminate = 'terminate' ;
then = 'then' ;
to = 'to' ;
transition = 'transition' ;
true = 'true';
try = 'try';
type = 'type';
unique = 'unique';
unlink = 'unlink';
unordered = 'unordered';
until = 'until';
update = 'update';
var = 'var';
when = 'when' ;
where = 'where';
while = 'while';
// arithmetic symbols
plus = '+' ;
minus = '-' ;
mult = '*' ;
div = '/';
assignop = ':=' ;
// relational symbols
equals = '=';
equals_equals = '=' '=';
not_equals_equals = exclamation '=' '=';
lab = '<' ;
lab_equals = '<' '=' ;
rab = '>' ;
rab_equals = '>' '=' ;
not_equals = exclamation '=' ;
elvis = '?' ':' ;
question = '?' ;
bangs = '!!' ;
// separator symbols
comma = ',' ;
colon = ':' ;
semicolon = ';' ;
dot = '.' ;
optional_dot = '?.' ;
namespace_separator = '::' ;
hash = '#' ;
l_paren = '(' ;
r_paren = ')' ;
l_bracket = '[';
r_bracket = ']';
l_curly_bracket = '{' ;
r_curly_bracket = '}' ;
right_arrow = '-' '>';
left_arrow = '<' '-';
l_guillemot = '«' ;
r_guillemot = '»' ;
// identifiers
identifier = (identifier_first_character | (escape_character input_character)) (identifier_following_character | (escape_character input_character))* ;
// numbers
integer = digit+ ;
real = digit+ '.' digit+ ;
// strings
string = quote [unicode_input_character - quote]* quote;
// uris
uri = '<' '<' [ascii_char - '>']* '>' '>' ;
// comments
comment = '/*' not_star + '*' + ( not_star_not_slash not_star * '*' + ) * '/' ;
model_comment = '(*' not_star + '*' + ( not_star_not_rbracket not_star * '*' + ) * ')' ;
// blanks
// blanks = sp | cr lf | cr | lf | tab ;
white_space = (sp | ht | ff | line_terminator)*;
Ignored Tokens
comment,
white_space ;
Productions
//******************************************************************************
//
// Basic structural specification syntax
//
//******************************************************************************
start = package_heading global_directive_section namespace_contents end dot;
package_heading =
model_comment? annotations? package_type qualified_identifier semicolon ;
package_type = {model} model | {profile} profile | {package} package;
qualified_identifier_list = qualified_identifier qualified_identifier_list_tail* ;
qualified_identifier_list_tail = comma qualified_identifier ;
qualified_identifier = qualified_identifier_base ;
forcefully_qualified_identifier = identifier qualified_identifier_tail ;
qualified_identifier_base = identifier qualified_identifier_tail? ;
qualified_identifier_tail = namespace_separator qualified_identifier_base;
global_directive_section = global_directive*;
global_directive = {load} load_decl | {apply} apply_profile_decl | {import} import_decl ;
// load <URI>
load_decl = load uri semicolon ;
// apply <id>
apply_profile_decl = apply qualified_identifier semicolon ;
// import <id>
import_decl = [optional_import_modifier]: visibility_modifier? import qualified_identifier optional_alias semicolon ;
optional_alias = alias identifier | {empty};
namespace_contents = top_level_element*;
sub_namespace = package_heading global_directive_section namespace_contents end semicolon;
// top-level elements
top_level_element = model_comment? top_level_element_choice ;
top_level_element_choice =
{class} class_def |
{association} association_def |
{stereotype} stereotype_def |
{operation} detached_operation_def |
{function} function_decl |
{primitive} primitive_def |
{subnamespace} sub_namespace;
// type identifiers
minimal_type_identifier = qualified_identifier;
single_type_identifier = {qualified} minimal_type_identifier template_binding? | {any} any | {tuple_type} tuple_type;
minimal_type_identifier_list = minimal_type_identifier minimal_type_identifier_list_tail* ;
minimal_type_identifier_list_tail = comma minimal_type_identifier ;
type_identifier = single_type_identifier optional_multiplicity? | {function} function_signature optional_multiplicity?;
optional_multiplicity = l_bracket multiplicity_spec r_bracket multiplicity_constraints?;
multiplicity_spec = {single} multiplicity_value | {interval} [lower]: multiplicity_value comma [upper]: multiplicity_value ;
multiplicity_constraints = l_curly_bracket multiplicity_constraint_list r_curly_bracket ;
multiplicity_constraint_list = multiplicity_constraint multiplicity_constraint_tail* ;
multiplicity_constraint_tail = comma multiplicity_constraint ;
multiplicity_constraint = {ordered} ordered | {unordered} unordered | {unique} unique | {nonunique} nonunique ;
// templates
optional_formal_template_parameters = lab formal_template_parameter_list rab;
formal_template_parameter_list = formal_template_parameter formal_template_parameter_tail* ;
formal_template_parameter_tail = comma formal_template_parameter ;
formal_template_parameter = identifier ;
template_binding = lab template_parameter_list rab ;
template_parameter_list = template_parameter template_parameter_tail* ;
template_parameter_tail = comma template_parameter ;
template_parameter = qualified_identifier ;
// associations
association_def = annotations? association_header association_role_decl_list end semicolon ;
association_header = association_kind identifier? ;
association_kind = {association} association | {aggregation} aggregation | {composition} composition ;
association_role_decl_list = association_role_decl association_role_decl_list | {empty};
association_role_decl = model_comment? annotations? association_modifiers association_end semicolon ;
association_end = {owned} association_owned_end | {member} association_member_end ;
association_owned_end = role identifier colon type_identifier ;
association_member_end = role [classifier]: qualified_identifier dot [property]: identifier ;
association_modifiers = association_modifier_list ;
association_modifier_list = association_modifier association_modifier_list | {empty} ;
association_modifier = {navigable} not? navigable | {readonly} readonly ;
// classes and interfaces
class_def = annotations? class_header feature_decl_list end semicolon;
class_header = class_modifiers class_type identifier optional_formal_template_parameters? class_specializes_section class_implements_section;
class_modifiers = class_modifier_list ;
class_modifier_list = class_modifier class_modifier_list | {empty} ;
class_modifier = {visibility} visibility_modifier | {abstract} abstract | {external} external | {role} role;
class_type = {class} clazz | {interface} interface | {datatype} datatype | {actor} actor | {signal} signal | {component} component | {enumeration} enumeration;
class_implements_section = implements class_implements_list | {empty} ;
class_implements_list = class_implements_item class_implements_list_tail* ;
class_implements_list_tail = comma class_implements_item ;
class_implements_item = annotations? minimal_type_identifier ;
class_specializes_section = specializes class_specializes_list | {empty} ;
class_specializes_list = class_specializes_item class_specializes_list_tail* ;
class_specializes_item = annotations? single_type_identifier ;
class_specializes_list_tail = comma class_specializes_item ;
// class features (operations and attributes)
feature_decl_list = feature_decl feature_decl_list | {empty} ;
feature_decl = model_comment? annotations? modifiers feature_type ;
modifiers = modifier_list ;
modifier_list = modifier modifier_list | {empty} ;
modifier = {visibility} visibility_modifier | {static} static | {abstract} abstract | {derived} derived | {readonly} readonly | {id} id;
visibility_modifier = {public} public | {private} private | {package} package | {protected} protected ;
feature_type =
{state_machine} state_machine_decl |
{operation} operation_decl |
{attribute} attribute_decl |
{literal} enumeration_literal_decl |
{reference} reference_decl |
{reception} reception_decl |
{port} port_decl |
{dependency} dependency_decl |
{invariant} class_invariant_decl |
{connector} connector_decl ;
state_machine_decl = statemachine identifier? state_decl* end semicolon ;
state_decl = model_comment? state_modifier_list state identifier? state_behavior* transition_decl* end semicolon ;
state_modifier_list = state_modifier*;
state_modifier = {initial} initial | {terminate} terminate | {final} final;
state_behavior = state_behavior_modifier state_behavior_definition semicolon ;
state_behavior_modifier = {do} do | {entry} entry | {exit} exit ;
state_behavior_definition = {name} identifier | {behavior} simple_block ;
transition_decl = model_comment? transition transition_triggers? to [destination]: identifier transition_guard? transition_effect? semicolon ;
transition_guard = when expression_block ;
transition_effect = do simple_block ;
transition_triggers = on transition_trigger transition_trigger_tail ;
transition_trigger_tail = comma transition_trigger transition_trigger_tail | {empty} ;
transition_trigger = {call} call l_paren identifier r_paren | {signal} signal l_paren identifier r_paren | {any} any;
reception_decl = reception [reception_name]: identifier? l_paren simple_param_decl r_paren semicolon optional_behavioral_feature_body;
operation_decl = operation_header operation_constraint* semicolon optional_behavioral_feature_body ;
parameterset_decl = model_comment? parameterset [name]: identifier? l_paren [parameters]: identifier_list r_paren ;
operation_constraint = model_comment? operation_constraint_kernel ;
operation_constraint_kernel = {precondition} operation_precondition | {permission} permission_constraint;
operation_precondition = precondition identifier? precondition_signature? constraint_exception? expression_block ;
permission_constraint = allow permission_roles access_capabilities permission_expression? ;
permission_expression = expression_block ;
permission_roles = qualified_identifier_list | {empty};
access_capabilities = access_capability_list | {all} all | {none} none | {empty};
access_capability_list = access_capability access_capability_tail*;
access_capability_tail = comma access_capability ;
access_capability = {read} read | {create} create | {update} update | {delete} delete | {call} call | {extent} extent;
precondition_signature = l_paren identifier_list r_paren ;
constraint_exception = raises [exception]: qualified_identifier ;
identifier_list = identifier identifier_list_tail* ;
identifier_list_tail = comma identifier ;
operation_header = operation_keyword wildcard_types? identifier signature ;
operation_keyword = {operation} operation | {query} query | {constructor} constructor;
wildcard_types = lab wildcard_type wildcard_type_tail rab ;
wildcard_type_tail = {empty} | comma wildcard_type wildcard_type_tail;
wildcard_type = identifier;
optional_behavioral_feature_body = behavioral_feature_body | {empty} ;
behavioral_feature_body = [block]: wordy_block semicolon ;
initialization_expression = {simple} simple_initialization | {complex} assignop expression_block ;
simple_initialization = assignop literal_or_identifier ;
attribute_decl = attribute identifier colon type_identifier optional_subsetting initialization_expression? attribute_invariant* semicolon ;
attribute_invariant = model_comment? annotations? invariant_kernel ;
enumeration_literal_decl = enumeration_literal? identifier enumeration_literal_slot_values? semicolon ;
enumeration_literal_slot_values = l_paren named_simple_value_list r_paren;
port_decl = port_modifier? port identifier? colon minimal_type_identifier port_connector? semicolon ;
port_modifier = {provided} provided | {required} required ;
port_connector = connector connector_end_list ;
connector_decl = connector connector_end_list semicolon ;
connector_end_list = connector_end connector_end_list_tail ;
connector_end_list_tail = comma connector_end_list | {empty} ;
connector_end =
{path} [prefix]: identifier dot [part_or_port]: identifier |
{simple} [part_or_port]: identifier ;
invariant_kernel = regular_invariant_constraint | {permission_constraint} permission_constraint;
regular_invariant_constraint = invariant identifier? constraint_exception? expression_block ;
constraint_keyword = {invariant} invariant ;
class_invariant_decl = invariant_kernel semicolon ;
reference_decl = reference_type identifier colon type_identifier optional_qualifier? optional_subsetting optional_opposite semicolon ;
optional_opposite = opposite [other_end]: identifier | {empty};
reference_type = {association} reference | {composition} composition | {aggregation} aggregation ;
dependency_decl = dependency type_identifier semicolon ;
optional_subsetting = subsets qualified_identifier | {empty};
optional_qualifier = by identifier ;
// primitive functions
function_decl = function identifier simple_signature semicolon ;
// tuple types
tuple_type = l_curly_bracket tuple_type_slot tuple_type_slot_tail r_curly_bracket ;
tuple_type_slot = identifier? colon type_identifier ;
tuple_type_slot_tail = comma tuple_type_slot tuple_type_slot_tail | {empty} ;
// signature
function_signature = l_curly_bracket simple_signature r_curly_bracket ;
signature = l_paren param_decl_list r_paren optional_return_type? optional_raises_section? parameterset_decl* ;
simple_signature = l_paren simple_param_decl_list r_paren simple_optional_return_type? ;
optional_return_type = annotations? simple_optional_return_type ;
simple_optional_return_type = colon type_identifier ;
param_decl_list = param_decl param_decl_list_tail | {empty} ;
simple_param_decl_list = simple_param_decl simple_param_decl_list_tail | {empty} ;
param_decl_list_tail = comma param_decl param_decl_list_tail | {empty} ;
simple_param_decl_list_tail = comma simple_param_decl simple_param_decl_list_tail | {empty} ;
param_decl = model_comment? annotations? parameter_modifiers simple_param_decl ;
simple_param_decl = optional_parameter_name? colon type_identifier initialization_expression? ;
optional_parameter_name = identifier ;
parameter_modifiers = parameter_modifier_list ;
parameter_modifier_list = parameter_modifier parameter_modifier_list | {empty} ;
parameter_modifier = {in} in | {out} out | {inout} inout | {read} read | {create} create | {update} update | {delete} delete;
optional_raises_section = raises raised_exception_list ;
raised_exception_list = raised_exception_item raised_exception_list_tail* ;
raised_exception_list_tail = comma raised_exception_item ;
raised_exception_item = minimal_type_identifier ;
// annotations
annotations = l_bracket annotation_list r_bracket ;
annotations_with_brackets = l_bracket annotation_list r_bracket;
annotations_with_guillemots = l_guillemot annotation_list r_guillemot;
annotation_list = annotation annotation_list_tail* ;
annotation_list_tail = comma annotation ;
annotation = qualified_identifier annotation_optional_value_specs? ;
annotation_optional_value_specs = l_paren annotation_value_spec_list r_paren ;
annotation_value_spec_list = annotation_value_spec annotation_value_spec_list_tail* ;
annotation_value_spec_list_tail = comma annotation_value_spec ;
annotation_value_spec = identifier equals annotation_value ;
annotation_value = literal | {enumerated} identifier;
// stereotype declaration
stereotype_def = annotations? stereotype_def_header stereotype_property_decl* end semicolon ;
stereotype_def_header = abstract? stereotype identifier stereotype_extends_section class_specializes_section ;
stereotype_extends_section = extends stereotype_extension_list | {empty} ;
stereotype_extension_list = stereotype_extension stereotype_extension_list_tail* ;
stereotype_extension_list_tail = comma stereotype_extension ;
stereotype_extension = qualified_identifier required?;
stereotype_property_decl = model_comment? property identifier colon type_identifier optional_default semicolon ;
optional_default = assignop literal | {empty};
primitive_def = annotations? visibility_modifier? primitive identifier semicolon ;
// detached operations
detached_operation_def = detached_operation_header behavioral_feature_body ;
detached_operation_header = operation [type]: minimal_type_identifier dot identifier semicolon ;
//******************************************************************************
//
// Behavior specification syntax
//
//******************************************************************************
simple_block = simple_block_resolved ;
simple_block_resolved = {expression} simple_expression_block | {statement} simple_statement_block ;
simple_expression_block = l_curly_bracket root_expression r_curly_bracket ;
simple_statement_block = l_curly_bracket block_kernel r_curly_bracket ;
wordy_block = begin block_kernel end ;
expression_block = simple_block ;
block_kernel = model_comment? var_decl_section statement_sequence ;
// local variable declaration
var_decl_section = var var_decl var_list_tail* semicolon | {empty} ;
var_decl = identifier optional_type? ;
optional_type = colon type_identifier ;
var_list_tail = comma var_decl ;
// statements
statement_sequence = statement*;
statement = annotations? statement_resolved semicolon ;
statement_resolved = {no_if} non_if_statement | {with_if} if_statement ;
non_if_statement = {block} wordy_block | {non_block} specific_statement ;
specific_statement =
{write_class_attribute} minimal_type_identifier hash identifier assignop root_expression |
{write_attribute} target identifier assignop root_expression |
{write_variable} identifier assignop root_expression |
{expression} root_expression |
{empty_return} return |
{valued_return} return root_expression |
{loop} loop_statement |
{link} link minimal_type_identifier l_paren [role1]: link_role comma [role2]: link_role r_paren |
{unlink} unlink minimal_type_identifier l_paren [role1]: link_role comma [role2]: link_role r_paren |
{send} send [signal]: minimal_type_identifier l_paren named_argument_list r_paren to [target]: root_expression |
{broadcast} broadcast [signal]: minimal_type_identifier |
{destroy} destroy root_expression |
{raise} raise root_expression |
{try} try_statement;
//
// try... catch... finally... end
//
try_statement = try [protected_block]: block_kernel catch_section? finally_section? end ;
catch_section = catch l_paren var_decl r_paren [handler_block]: block_kernel ;
finally_section = finally [finally_block]: block_kernel ;
//
// if statement
//
if_statement = if if_clause rest_if;
if_clause = [test]: root_expression then clause_body ;
rest_if = {elseif} elseif if_clause rest_if | {else} else clause_body | {empty} ;
clause_body = non_if_statement ;
// loop statements
loop_statement =
{while} while_statement |
{repeat} repeat_statement ;
loop_test = root_expression ;
while_statement = while loop_test do while_loop_body ;
while_loop_body = non_if_statement ;
// repeat statement
repeat_statement = repeat repeat_loop_body until loop_test ;
repeat_loop_body = statement_sequence ;
identifier_expression =
{variable} variable_access |
{class_attribute} minimal_type_identifier hash identifier |
{class_operation} minimal_type_identifier hash identifier l_paren expression_list r_paren |
{new} new minimal_type_identifier |
{self} self |
{link} identifier_expression association_traversal |
{attribute} target identifier |
{operation} target identifier l_paren expression_list r_paren |
{extent} minimal_type_identifier extent |
{function} variable_access l_paren expression_list r_paren ;
association_traversal =
{simple} right_arrow identifier |
{qualified} left_arrow minimal_type_identifier right_arrow identifier ;
variable_access = identifier ;
link_role = identifier assignop root_expression ;
target = operand object_dot ;
object_dot = {required_target} dot | {optional_target} optional_dot ;
// closures
closure = simple_signature [block]: simple_block ;
named_argument_list = named_argument named_argument_additional * | {empty} ;
named_argument = identifier assignop expression ;
named_argument_additional = comma named_argument ;
named_simple_value_list = named_simple_value named_simple_value_additional * | {empty} ;
named_simple_value = identifier assignop literal_or_identifier ;
named_simple_value_additional = comma named_simple_value ;
// expressions
expression_list =
expression_list_element expression_list_tail* | {empty} ;
expression_list_tail = comma expression_list_element ;
expression_list_element = expression;
root_expression = expression ;
expression = expression_p5 ;
expression_p0 =
{alt} operand |
{alt_unary} [operator]: unary_op_level0 [operand]: expression_p0 ;
expression_p1 =
{alt_binary} [operand1]: expression_p0 [operator]: binary_op_level1 [operand2]: expression_p1 |
{alt_nested} expression_p0;
expression_p2 =
{alt_binary} [operand1]: expression_p1 [operator]: binary_op_level2 [operand2]: expression_p2 |
{alt_nested} expression_p1 ;
expression_p3 =
{alt_binary} [operand1]: expression_p2 [operator]: binary_op_level3 [operand2]: expression_p3 |
{alt_nested} expression_p2;
expression_p4 =
// {alt_unary} [operator]: unary_op_level4 [operand]: expression_p4 |
{alt_binary} [operand1]: expression_p3 [operator]: binary_op_level4 [operand2]: expression_p4 |
{alt_nested} expression_p3 ;
expression_p5 =
{alt_binary} [operand1]: expression_p4 [operator]: binary_op_level5 [operand2]: expression_p5 |
{alt_ternary} ternary_expression |
{alt_nested} expression_p4;
ternary_expression = [condition]: expression_p4 question [true_expression]: expression_p5 colon [false_expression]: expression_p5 ;
unary_op_level0 = {not} not | {minus} minus | {not_null} question | {required} bangs;
binary_op_level1 = plus_minus;
binary_op_level2 = {mult_div} mult_div | {elvis} elvis ;
binary_op_level3 = comparison_operator;
binary_op_level4 = and;
binary_op_level5 = or;
is_class_expression = [operand1]: operand [operator]: is [operand2]: minimal_type_identifier ;
operand =
{identifier_expression} identifier_expression |
{literal} literal |
{empty_set} empty_set |
{tuple} tuple_constructor |
{parenthesis} l_paren expression cast? r_paren |
{is_class} is_class_expression |
{closure} closure ;
empty_set = minimal_type_identifier l_bracket r_bracket ;
cast = as [type_identifier]: type_identifier ;
mult_div =
{mult} mult |
{div} div ;
plus_minus =
{plus} plus |
{minus} minus;
comparison_operator =
{same} equals_equals |
{not_same} not_equals_equals |
{equals} equals |
{not_equals} not_equals |
{lower_than} lab |
{greater_than} rab |
{greater_or_equals} rab_equals |
{lower_or_equals} lab_equals;
literal = {boolean} boolean | {number} number | {string} string | {null} null;
tuple_constructor = l_curly_bracket tuple_component_value tuple_component_value_tail* r_curly_bracket ;
tuple_component_value = identifier assignop expression ;
tuple_component_value_tail = comma tuple_component_value ;
literal_or_identifier = {literal} literal | {identifier} identifier;
boolean = {true} true | {false} false ;
number =
{integer} integer |
{real} real ;
multiplicity_value = {integer} integer | {infinity} mult ;