sdl92.g 34.5 KB
Newer Older
dbarbera's avatar
dbarbera committed
1
/*
Maxime Perrotin's avatar
Maxime Perrotin committed
2
3
    OpenGEODE
    ANTLR 3.1.3 grammar for the SDL92 langage
4
5
6
    Includes the following features from SDL2000+:
    - FOR loops in TASKs
    - Composite states
Maxime Perrotin's avatar
Maxime Perrotin committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

    author: Maxime Perrotin
*/

grammar sdl92;

options {
    language=Python;
    output=AST;
    ASTLabelType=CommonTree;
    backtrack=true;
}

tokens {
        ACTION;
dbarbera's avatar
dbarbera committed
22
        ALL;
Maxime Perrotin's avatar
Maxime Perrotin committed
23
24
        ALTERNATIVE;
        ANSWER;
dbarbera's avatar
dbarbera committed
25
26
27
28
29
30
31
32
        ARRAY;
        ASN1;
        ASSIGN;
        BITSTR;
        BLOCK;
        CHANNEL;
        CHOICE;
        CIF;
Maxime Perrotin's avatar
Maxime Perrotin committed
33
        CLOSED_RANGE;
dbarbera's avatar
dbarbera committed
34
35
        COMMENT;
        COMPOSITE_STATE;
36
        CONDITIONAL;
dbarbera's avatar
dbarbera committed
37
38
        CONNECT;
        CONNECTION;
Maxime Perrotin's avatar
Maxime Perrotin committed
39
        CONSTANT;
dbarbera's avatar
dbarbera committed
40
41
42
43
        CONSTANTS;
        DCL;
        DECISION;
        DIGITS;
Maxime Perrotin's avatar
Maxime Perrotin committed
44
        ELSE;
dbarbera's avatar
dbarbera committed
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
        EMPTYSTR;
        ENDNEWTYPE;
        ENDSYNTYPE;
        ENDTEXT;
        EXPORT;
        EXPRESSION;
        EXTERNAL;
        FI;
        FIELD;
        FIELD_NAME;
        FIELDS;
        FLOAT2;
        FLOAT;
        FLOATING_LABEL;
        FOR;
        FPAR;
        GROUND;
        HYPERLINK;
        IF;
        IFTHENELSE;
        IN;
        INFORMAL_TEXT;
        INOUT;
        INPUT;
        INPUT_NONE;
        INPUTLIST;
        JOIN;
        LABEL;
73
        LITERAL;
dbarbera's avatar
dbarbera committed
74
75
76
77
78
79
        NEG;
        NEWTYPE;
        NEXTSTATE;
        NUMBER_OF_INSTANCES;
        OCTSTR;
        OPEN_RANGE;
Maxime Perrotin's avatar
Maxime Perrotin committed
80
81
        OUTPUT;
        OUTPUT_BODY;
dbarbera's avatar
dbarbera committed
82
83
        PARAM;
        PARAMNAMES;
Maxime Perrotin's avatar
Maxime Perrotin committed
84
        PARAMS;
85
        PAREN;
86
        PFPAR;
Maxime Perrotin's avatar
Maxime Perrotin committed
87
        PRIMARY;
dbarbera's avatar
dbarbera committed
88
89
90
91
92
        PROCEDURE;
        PROCEDURE_CALL;
        PROCEDURE_NAME;
        PROCESS;
        PROVIDED;
Maxime Perrotin's avatar
Maxime Perrotin committed
93
        QUESTION;
dbarbera's avatar
dbarbera committed
94
95
96
        RANGE;
        RESET;
        RETURN;
Maxime Perrotin's avatar
Maxime Perrotin committed
97
        ROUTE;
dbarbera's avatar
dbarbera committed
98
        SAVE;
99
        SELECTOR;
dbarbera's avatar
dbarbera committed
100
101
102
103
104
105
106
107
108
109
        SEQOF;
        SEQUENCE;
        SET;
        SIGNAL;
        SIGNAL_LIST;
        SORT;
        STATE;
        STATELIST;
        STIMULUS;
        STOP;
Maxime Perrotin's avatar
Maxime Perrotin committed
110
        STOPIF;
dbarbera's avatar
dbarbera committed
111
        STRING;
112
        STRUCT;
113
114
        SYNONYM;
        SYNONYM_LIST;
dbarbera's avatar
dbarbera committed
115
116
117
118
119
120
121
122
123
124
125
126
        SYNTYPE;
        SYSTEM;
        TASK;
        TASK_BODY;
        TERMINATOR;
        TEXT;
        TEXTAREA;
        TEXTAREA_CONTENT;
        THEN;
        TIMER;
        TO;
        TRANSITION;
127
        TYPE_INSTANCE;
dbarbera's avatar
dbarbera committed
128
129
130
131
132
133
        USE;
        VALUE;
        VARIABLE;
        VARIABLES;
        VIA;
        VIAPATH;
Maxime Perrotin's avatar
Maxime Perrotin committed
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
}


/*
    Top level: any .pr file
*/

pr_file
        :       (use_clause
                | system_definition
                | process_definition)+;


system_definition
        :       SYSTEM system_name end
                entity_in_system*
                ENDSYSTEM system_name? end
        ->      ^(SYSTEM system_name entity_in_system*);


use_clause
        :       use_asn1?
156
157
158
159
                USE package_name
                ('/' def_selection_list )?
                end
        ->      ^(USE use_asn1? end? package_name def_selection_list?);
Maxime Perrotin's avatar
Maxime Perrotin committed
160

161
162
163
164
165
/*
    In USE clause: USE package/X, Y, Z;
*/
def_selection_list
        :       ID (','! ID)*;
Maxime Perrotin's avatar
Maxime Perrotin committed
166
167
168
169
170
171

/* Entity in system:
   Declare signals, external procedures, connections and blocks
*/
entity_in_system
        :       signal_declaration
172
                | text_area
Maxime Perrotin's avatar
Maxime Perrotin committed
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
                | procedure
                | channel
                | block_definition;

/* signal_declaration:
   e.g. SIGNAL open_door(typeA, typeB);
*/
signal_declaration
        :       paramnames?
                SIGNAL signal_id input_params? end
        ->      ^(SIGNAL paramnames? signal_id input_params?);


channel
        :       CHANNEL channel_id
                route+
                ENDCHANNEL end
        ->      ^(CHANNEL channel_id route+);


route
        :       FROM source_id TO dest_id WITH signal_id (',' signal_id)* end
        ->      ^(ROUTE source_id dest_id signal_id+);


block_definition
        :       BLOCK block_id end
dbarbera's avatar
dbarbera committed
200
                entity_in_block*
Maxime Perrotin's avatar
Maxime Perrotin committed
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
                ENDBLOCK end
        ->      ^(BLOCK block_id entity_in_block*);


/* Inside a SDL block:
   there can be nested blocks, processes, signalroutes and connections
   to above channels
*/
entity_in_block
        :       signal_declaration
                | signalroute
                | connection
                | block_definition
                | process_definition;


signalroute
        :       SIGNALROUTE route_id
                route+
        ->      ^(SIGNALROUTE route_id route+);


connection
        :       CONNECT channel_id AND route_id end
        ->      ^(CONNECTION channel_id route_id);


process_definition
        :       PROCESS process_id number_of_instances? REFERENCED end
        ->      ^(PROCESS process_id number_of_instances? REFERENCED)
231
                | cif? PROCESS process_id number_of_instances? end
232
                pfpar?
233
                (text_area | procedure | composite_state)*
Maxime Perrotin's avatar
Maxime Perrotin committed
234
235
                processBody? ENDPROCESS process_id?
                end
236
237
238
239
240
241
        ->      ^(PROCESS cif? process_id number_of_instances? end?
                pfpar? text_area* procedure* composite_state* processBody?)
                | cif? PROCESS process_id number_of_instances? (':' type_inst)?
                end
        ->      ^(PROCESS cif? process_id type_inst? number_of_instances? end?)
        ;
Maxime Perrotin's avatar
Maxime Perrotin committed
242

243
244
245
246
247
248
249
250
251
252
253
// Process formal parameters
pfpar
        :       FPAR parameters_of_sort
                (',' parameters_of_sort)*
                end
        ->      ^(PFPAR parameters_of_sort+);

parameters_of_sort
        :       variable_id (',' variable_id)* sort
        ->      ^(PARAM variable_id+ sort);

Maxime Perrotin's avatar
Maxime Perrotin committed
254

255
256
// procedure: missing the RETURNS statement
// (TODO - but check new SDL2000 syntax that has no RETURNS token)
Maxime Perrotin's avatar
Maxime Perrotin committed
257
258
procedure
        :       cif?
259
                PROCEDURE procedure_id e1=end
Maxime Perrotin's avatar
Maxime Perrotin committed
260
261
262
                fpar?
                (text_area | procedure)*
                ((processBody? ENDPROCEDURE procedure_id?) | EXTERNAL)
263
264
                e2=end
        ->      ^(PROCEDURE cif? procedure_id $e1? $e2? fpar?
Maxime Perrotin's avatar
Maxime Perrotin committed
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
                text_area* procedure* processBody? EXTERNAL?);


// Procedure formal parameters
fpar
        :       FPAR formal_variable_param
                (',' formal_variable_param)*
                end
        ->      ^(FPAR formal_variable_param+);


formal_variable_param
        :       (INOUT | IN)?
                variable_id (',' variable_id)* sort
        ->      ^(PARAM INOUT? IN? variable_id+ sort);


// text_area: TODO add operator description in content
text_area
        :       cif
                content?
                cif_end_text
        ->      ^(TEXTAREA cif content? cif_end_text);


// Text areas can contain textual procedures, FPAR declarations,
// and variable or timer declarations
content
        :        (procedure
294
295
                 | use_clause
                 | signal_declaration
Maxime Perrotin's avatar
Maxime Perrotin committed
296
297
                 | fpar
                 | timer_declaration
298
299
                 | syntype_definition
                 | newtype_definition
300
301
                 | variable_definition
                 | synonym_definition)*
Maxime Perrotin's avatar
Maxime Perrotin committed
302
303
        ->       ^(TEXTAREA_CONTENT fpar* procedure* variable_definition*
                   syntype_definition* newtype_definition* timer_declaration*
304
                   signal_declaration* use_clause* synonym_definition*);
Maxime Perrotin's avatar
Maxime Perrotin committed
305
306
307
308
309
310
311
312


timer_declaration
        :       TIMER timer_id
                (',' timer_id)*
                end
        ->      ^(TIMER timer_id+);

313
syntype_definition
Maxime Perrotin's avatar
Maxime Perrotin committed
314
315
316
317
318
319
320
        :       SYNTYPE syntype_name '=' parent_sort
                (CONSTANTS (range_condition (',' range_condition)* ))?
                ENDSYNTYPE syntype_name? end
        ->      ^(SYNTYPE syntype_name parent_sort range_condition*);

syntype_name
        :       sort;
321
322

parent_sort
Maxime Perrotin's avatar
Maxime Perrotin committed
323
        :       sort;
324
325

newtype_definition
Maxime Perrotin's avatar
Maxime Perrotin committed
326
327
328
        :       NEWTYPE type_name (array_definition|structure_definition)?
                ENDNEWTYPE type_name? end
        ->      ^(NEWTYPE type_name array_definition* structure_definition*);
329
330
331


type_name
Maxime Perrotin's avatar
Maxime Perrotin committed
332
333
        :       sort;

334
array_definition
Maxime Perrotin's avatar
Maxime Perrotin committed
335
336
        :       ARRAY '(' sort ',' sort ')'
        ->      ^(ARRAY sort sort);
337
338

structure_definition
Maxime Perrotin's avatar
Maxime Perrotin committed
339
340
        :       STRUCT field_list end
        ->      ^(STRUCT field_list);
341
342

field_list
Maxime Perrotin's avatar
Maxime Perrotin committed
343
344
        :       field_definition (end field_definition)*
        ->      ^(FIELDS field_definition+);
345
346

field_definition
Maxime Perrotin's avatar
Maxime Perrotin committed
347
348
        :       field_name (',' field_name)* sort
        ->      ^(FIELD field_name+ sort);
349

Maxime Perrotin's avatar
Maxime Perrotin committed
350
351
352
353
354
355
variable_definition
        :       DCL variables_of_sort
                (',' variables_of_sort)*
                end
        ->      ^(DCL variables_of_sort+);

Maxime Perrotin's avatar
Maxime Perrotin committed
356
357
358
synonym_definition
        :       internal_synonym_definition;

359
internal_synonym_definition
Maxime Perrotin's avatar
Maxime Perrotin committed
360
361
362
363
        :       SYNONYM synonym_definition_item (',' synonym_definition_item)*
                end
        ->      ^(SYNONYM_LIST synonym_definition_item+);

364
synonym_definition_item
Maxime Perrotin's avatar
Maxime Perrotin committed
365
366
        :       sort sort '=' ground_expression
        ->      ^(SYNONYM sort sort ground_expression);
Maxime Perrotin's avatar
Maxime Perrotin committed
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389

variables_of_sort
        :       variable_id (',' variable_id)* sort (':=' ground_expression)?
        ->      ^(VARIABLES variable_id+ sort ground_expression?);


ground_expression
        :       expression
        ->      ^(GROUND expression);


number_of_instances
        :       '(' initial_number=INT ',' maximum_number=INT ')'
        ->      ^(NUMBER_OF_INSTANCES $initial_number $maximum_number);


processBody
        :       start? (state | floating_label)*;


start
        :       cif?
                hyperlink?
390
                START name=state_entry_point_name? end
Maxime Perrotin's avatar
Maxime Perrotin committed
391
                transition?
392
        ->      ^(START cif? hyperlink? $name? end? transition?);
Maxime Perrotin's avatar
Maxime Perrotin committed
393
394
395
396
397
398
399
400
401
402
403
404
405


floating_label
        :       cif?
                hyperlink?
                CONNECTION connector_name ':'
                transition?
                cif_end_label?
                ENDCONNECTION SEMI
        ->      ^(FLOATING_LABEL cif? hyperlink? connector_name transition?);


state
406
        :       cif?
Maxime Perrotin's avatar
Maxime Perrotin committed
407
408
409
410
411
412
413
414
415
                hyperlink?
                STATE statelist e=end
                (state_part)*
                ENDSTATE statename? f=end
        ->      ^(STATE cif? hyperlink? $e? statelist state_part*);


statelist
        :       ((statename)(',' statename)*)
416
        ->      ^(STATELIST statename+)
Maxime Perrotin's avatar
Maxime Perrotin committed
417
418
419
420
421
                | ASTERISK exception_state?
        ->      ^(ASTERISK exception_state?);


exception_state
422
        :       '(' statename (',' statename)* ')'
Maxime Perrotin's avatar
Maxime Perrotin committed
423
424
425
        ->      statename+;


426
427
428
composite_state
        :       STATE statename e=end
                SUBSTRUCTURE
429
                connection_points*
430
431
                body=composite_state_body
                ENDSUBSTRUCTURE statename? f=end
432
        ->      ^(COMPOSITE_STATE statename connection_points* $body $e?);
433
434
435


connection_points
436
437
438
439
        :       IN state_entry_exit_points end
        ->      ^(IN state_entry_exit_points end?)
                | OUT state_entry_exit_points end
        ->      ^(OUT state_entry_exit_points end?);
440
441
442
443
444
445
446
447
448


state_entry_exit_points
        :       '(' statename (',' statename)* ')'
        ->      statename+;


composite_state_body
        :       (text_area | procedure | composite_state)*
Maxime Perrotin's avatar
Maxime Perrotin committed
449
                start* (state | floating_label)*;
450
451


Maxime Perrotin's avatar
Maxime Perrotin committed
452
453
454
455
456
state_part
        :       input_part
                //| priority_input        // Not supported
                | save_part               // Not supported in openGEODE
                | spontaneous_transition
457
458
459
460
461
462
                | continuous_signal       // Not supoorted in openGEODE
                | connect_part;


// connect part is used to connect nested state exit points to a transition
connect_part
Maxime Perrotin's avatar
Maxime Perrotin committed
463
464
465
466
467
        :       cif?
                hyperlink?
                CONNECT connect_list? end
                transition?
        ->      ^(CONNECT cif? hyperlink? connect_list? end? transition?);
468
469
470
471
472
473


connect_list
        :       state_exit_point_name (',' state_exit_point_name)*
                -> state_exit_point_name+
                | ASTERISK;
Maxime Perrotin's avatar
Maxime Perrotin committed
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490


spontaneous_transition
        :       cif?
                hyperlink?
                INPUT NONE end
                enabling_condition?
                transition
        ->      ^(INPUT_NONE cif? hyperlink? transition);


enabling_condition
        :       PROVIDED expression end
        ->      ^(PROVIDED expression);


continuous_signal
dbarbera's avatar
dbarbera committed
491
        :       PROVIDED expression end
492
                (PRIORITY integer_literal_name=INT end)?
Maxime Perrotin's avatar
Maxime Perrotin committed
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
                transition
        ->      ^(PROVIDED expression $integer_literal_name? transition);


save_part
        :       SAVE save_list
                end
        ->      ^(SAVE save_list);


save_list
        :       signal_list
                | asterisk_save_list;


asterisk_save_list
        :       ASTERISK;


signal_list
        :       signal_item (',' signal_item)*
        ->      ^(SIGNAL_LIST signal_item+);



// Signal_item alternatives are all of the same ID type.
// Should be resolved at semantic analysis.
signal_item
        :       signal_id; /* |
                priority_signal_id |
                signal_list_id |
                timer_id;*/

dbarbera's avatar
dbarbera committed
526
/*   Not considered for the moment
Maxime Perrotin's avatar
Maxime Perrotin committed
527
528
     (irrelevant in the scope of the generation of code for a single process)
priority_input
dbarbera's avatar
dbarbera committed
529
        :       PRIORITY INPUT priority_input_list end transition;
Maxime Perrotin's avatar
Maxime Perrotin committed
530
531
532
533
534
535
536
537
538
539
540
541
542
543


priority_input_list
        :       priority_stimulus (',' priority_stimulus)*;

priority_stimulus
        :       priority_signal_id ( '(' variable_id (',' variable_id)* ')');
*/


// this is only the "basic input part" from SDL92
input_part
        :       cif?
                hyperlink?
Maxime Perrotin's avatar
Maxime Perrotin committed
544
545
                INPUT inputlist end
                enabling_condition?
Maxime Perrotin's avatar
Maxime Perrotin committed
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
                transition?
        ->      ^(INPUT cif? hyperlink? end?
                inputlist enabling_condition? transition?);


// asterisk means: all signals not excplicitely specified
// (semantic is different from asterisk state)
inputlist
        :       ASTERISK
                | (stimulus (',' stimulus)*)
        ->      ^(INPUTLIST stimulus+);


stimulus
        :       stimulus_id input_params?;


input_params
        :       L_PAREN variable_id (',' variable_id)* R_PAREN
        ->      ^(PARAMS variable_id+);


transition
        :       action+ label? terminator_statement?
        ->      ^(TRANSITION action+ label? terminator_statement?)
                | terminator_statement
        ->      ^(TRANSITION terminator_statement);


action
        :       label?
                (task
                | task_body
                | output
                | create_request
                | decision
                | transition_option
                | set_timer
                | reset_timer
                | export     // Not supported in OpenGEODE
                | procedure_call);

export
        :       EXPORT
                L_PAREN variable_id (COMMA variable_id)* R_PAREN
                end
        ->      ^(EXPORT variable_id+);

/*
remote_procedure_call
dbarbera's avatar
dbarbera committed
596
        :       CALL remote_procedure_call_body;
Maxime Perrotin's avatar
Maxime Perrotin committed
597
598

remote_procedure_call_body
dbarbera's avatar
dbarbera committed
599
        :       remote_procedure_id actual_parameters? (TO destination)?;
Maxime Perrotin's avatar
Maxime Perrotin committed
600
601
602
603
604
605
606
607
608
609
610
*/


procedure_call
        :       cif?
                hyperlink?
                CALL procedure_call_body end
        ->      ^(PROCEDURE_CALL cif? hyperlink? end? procedure_call_body);


procedure_call_body
dbarbera's avatar
dbarbera committed
611
        :       procedure_id actual_parameters?
Maxime Perrotin's avatar
Maxime Perrotin committed
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
        ->      ^(OUTPUT_BODY procedure_id actual_parameters?);


set_timer
        :       SET set_statement (COMMA set_statement)*
                end
        ->      set_statement+;


set_statement
        :       L_PAREN (expression COMMA)? timer_id R_PAREN
        ->      ^(SET expression? timer_id);
        // ('('expression_list')')? ')'; (removed because of non-LL(*) problem)


reset_timer
        :       RESET reset_statement (',' reset_statement)*
                end
        ->      reset_statement+;


reset_statement
        :       timer_id ('(' expression_list ')')?
        ->      ^(RESET timer_id expression_list?);


transition_option
        :       ALTERNATIVE alternative_question e=end
                answer_part
                alternative_part
                ENDALTERNATIVE f=end
        ->      ^(ALTERNATIVE answer_part alternative_part);


alternative_part
        :       (answer_part+ else_part?)
        ->      answer_part+ else_part?
                | else_part
        ->      else_part;


alternative_question
        :       expression
                | informal_text;


decision
        :       cif?
                hyperlink?
                DECISION question e=end
                answer_part?
                alternative_part?
                ENDDECISION f=end
        ->      ^(DECISION cif? hyperlink? $e? question
                answer_part? alternative_part?);


answer_part
        :       cif?
                hyperlink?
                L_PAREN answer R_PAREN ':' transition?
        ->      ^(ANSWER cif? hyperlink? answer transition?);


answer
        :       range_condition
                | informal_text;


else_part
        :       cif?
                hyperlink?
                ELSE ':' transition?
        ->      ^(ELSE cif? hyperlink? transition?);


question
689
690
        :       informal_text
                | expression
Maxime Perrotin's avatar
Maxime Perrotin committed
691
692
693
694
695
696
697
698
699
700
701
        ->      ^(QUESTION expression)
                | ANY
        ->      ^(ANY);


range_condition
        :       (closed_range | open_range);
                //(',' (closed_range|open_range))*;


closed_range
702
        :       a=expression ':' b=expression
Maxime Perrotin's avatar
Maxime Perrotin committed
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
        ->      ^(CLOSED_RANGE $a $b);


open_range
        :       constant
        ->      constant
                | ( (EQ|NEQ|GT|LT|LE|GE) constant)
        ->      ^(OPEN_RANGE EQ? NEQ? GT? LT? LE? GE? constant);


constant
        :       expression
        ->      ^(CONSTANT expression);


create_request
dbarbera's avatar
dbarbera committed
719
        :       CREATE
Maxime Perrotin's avatar
Maxime Perrotin committed
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
                createbody
                actual_parameters?
                end
        ->      ^(CREATE createbody actual_parameters?);


createbody
        :       process_id
                | THIS;


output
        :       cif?
                hyperlink?
                OUTPUT outputbody end
        ->      ^(OUTPUT cif? hyperlink? end? outputbody);


outputbody
739
740
741
742
        :       outputstmt (',' outputstmt)* to_part?
        ->      ^(OUTPUT_BODY outputstmt+ to_part?);
 //               via_part?
 //     -> (signal_id actual_parameters?)+ to_part? via_part?;
Maxime Perrotin's avatar
Maxime Perrotin committed
743
744
745


outputstmt
dbarbera's avatar
dbarbera committed
746
        :       signal_id
Maxime Perrotin's avatar
Maxime Perrotin committed
747
748
                actual_parameters?;

749
to_part
Maxime Perrotin's avatar
Maxime Perrotin committed
750
751
        :       (TO destination)
        ->      ^(TO destination);
Maxime Perrotin's avatar
Maxime Perrotin committed
752

753
via_part
dbarbera's avatar
dbarbera committed
754
755
        :       VIA viabody
        ->      ^(VIA viabody);
Maxime Perrotin's avatar
Maxime Perrotin committed
756
757
758
759


// ambiguous in SDL92, added OR between ALL and via_path
viabody
dbarbera's avatar
dbarbera committed
760
        :       ALL
Maxime Perrotin's avatar
Maxime Perrotin committed
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
        ->      ^(ALL)
                | via_path
        ->      ^(VIAPATH via_path);


destination
        :       pid_expression
                | process_id
                | THIS;


via_path
        :       via_path_element (',' via_path_element)*
        ->      via_path_element+;


via_path_element
        :       ID; // signal_route_id | channel_id | gate_id;


actual_parameters
        :      '(' expression (',' expression)* ')'
        ->     ^(PARAMS expression+);


task
        :       cif?
                hyperlink?
789
790
                TASK task_body? end
        ->      ^(TASK cif? hyperlink? end? task_body?);
Maxime Perrotin's avatar
Maxime Perrotin committed
791
792
793
794
795
796
797
798
799
800
801
802
803


task_body
        :       (assignement_statement (',' assignement_statement)*)
        ->      ^(TASK_BODY assignement_statement+)
                | (informal_text (',' informal_text)*)
        ->      ^(TASK_BODY informal_text+)
                | (forloop (',' forloop)*)
        ->      ^(TASK_BODY forloop+)
        ;

// SDL extension - FOR loop in TASKs
forloop
804
        :       FOR variable_id IN (range | variable) ':'
Maxime Perrotin's avatar
Maxime Perrotin committed
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
                transition?
                ENDFOR
        ->      ^(FOR variable_id variable? range? transition?);

range
        :       RANGE
                L_PAREN a=ground_expression
                (COMMA b=ground_expression)? (COMMA step=INT)?
                R_PAREN
        ->      ^(RANGE $a $b? $step?);

assignement_statement
        :       variable ':=' expression
        ->      ^(ASSIGN variable expression);


// Variable: covers eg. toto(5)(4)!titi(3)!tutu!yoyo
variable
823
        :       postfix_expression
dbarbera's avatar
dbarbera committed
824
825
        |       ID                     ->  ^(VARIABLE ID);

Maxime Perrotin's avatar
Maxime Perrotin committed
826
827
828
829

field_selection
        :       (('!'|'.') field_name);

830

dbarbera's avatar
dbarbera committed
831
expression
832
833
        :       binary_expression;

834

835
836
837
838
839
840
841
842
843
844
845
846
847
binary_expression
        :       binary_expression_0 ( IMPLIES^ binary_expression_0)*;
binary_expression_0
        :       binary_expression_1 (( (OR^ ELSE?) | XOR^ ) binary_expression_1)*;
binary_expression_1
        :       binary_expression_2 ( AND^ THEN? binary_expression_2)*;
binary_expression_2
        :       binary_expression_3 (( EQ^ | NEQ^ | GT^ | GE^ | LT^ | LE^ | IN^ ) binary_expression_3)*;
binary_expression_3
        :       binary_expression_4 (( PLUS^ | DASH^ | APPEND^ ) binary_expression_4)*;
binary_expression_4
        :       unary_expression (( ASTERISK^ | DIV^ | MOD^ | REM^ ) unary_expression)*;

848

849
unary_expression
850
851
        :       postfix_expression
        |       primary_expression
852
        |       NOT^ unary_expression
853
854
855
856
857
858
859
860
861
862
863
        |       DASH unary_expression -> ^(NEG unary_expression)
        ;


postfix_expression
        :       (ID -> ^(PRIMARY ^(VARIABLE ID)))
                (   '(' params=expression_list ')' -> ^(CALL $postfix_expression ^(PARAMS $params))
                |   '!' field_name  -> ^(SELECTOR $postfix_expression field_name)
                )+
        ;

864
865
866

primary_expression
        :       primary                       -> ^(PRIMARY primary)
867
        |       '(' expression ')'            -> ^(PAREN expression)
868
        |       conditional_expression
869
        ;
Maxime Perrotin's avatar
Maxime Perrotin committed
870

871

872
primary
873
874
        :       BITSTR^
        |       OCTSTR^
Maxime Perrotin's avatar
Maxime Perrotin committed
875
876
        |       TRUE^
        |       FALSE^
877
        |       STRING
Maxime Perrotin's avatar
Maxime Perrotin committed
878
879
880
        |       NULL^
        |       PLUS_INFINITY^
        |       MINUS_INFINITY^
881
882
        |       INT^
        |       FLOAT^
883
        |       ID ':' expression           -> ^(CHOICE ID expression)
dbarbera's avatar
dbarbera committed
884
        |       ID                          -> ^(VARIABLE ID)
885
886
        |       '{' '}'                     -> ^(EMPTYSTR)
        |       '{'
Maxime Perrotin's avatar
Maxime Perrotin committed
887
888
                MANTISSA mant=INT COMMA
                BASE bas=INT COMMA
dbarbera's avatar
dbarbera committed
889
                EXPONENT exp=INT
890
891
                '}'                         -> ^(FLOAT2 $mant $bas $exp)
        |       '{'
892
893
                named_value (COMMA named_value)*
                '}'                         -> ^(SEQUENCE named_value+)
894
        |       '{'
895
896
                primary (COMMA primary)*
                '}'                         -> ^(SEQOF primary+)
897
        |       STATE^
Maxime Perrotin's avatar
Maxime Perrotin committed
898
899
        ;

900

Maxime Perrotin's avatar
Maxime Perrotin committed
901
informal_text
902
903
        :        STRING
        ->       ^(INFORMAL_TEXT STRING);
Maxime Perrotin's avatar
Maxime Perrotin committed
904
905
906


// { a 5 } (SEQUENCE field value)
907
named_value
Maxime Perrotin's avatar
Maxime Perrotin committed
908
909
910
911
912
913
914
915
916
917
        :       ID expression;


primary_params
        :      '(' expression_list ')'
        ->     ^(PARAMS expression_list)
               | '!' literal_id
        ->     ^(FIELD_NAME literal_id);


dbarbera's avatar
dbarbera committed
918
/* All cases are covered by the ground primary
Maxime Perrotin's avatar
Maxime Perrotin committed
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
   above (Except structure primary, but we favour ASN.1 notation)
extended_primary
        :       synonym         |
                indexed_primary |
                field_primary   |
                structure_primary;
*/


indexed_primary
        :       primary '(' expression_list ')';


field_primary
        :       primary field_selection;


structure_primary
        :       '(.' expression_list '.)';
// Removed "qualifier" from the standard
// (to be put later, but never used in practice)


active_expression
        :       active_primary;


active_primary
        :       variable_access
                | operator_application
                | conditional_expression
                | imperative_operator
                | '(' active_expression ')'
                | 'ERROR';
   // active_extended_primary removed because not defined in the standard


imperative_operator
        :       now_expression
                | import_expression
                | pid_expression
                | view_expression
                | timer_active_expression
                | anyvalue_expression;


timer_active_expression
dbarbera's avatar
dbarbera committed
966
        :       ACTIVE '(' timer_id ('(' expression_list ')')? ')';
Maxime Perrotin's avatar
Maxime Perrotin committed
967
968
969


anyvalue_expression
dbarbera's avatar
dbarbera committed
970
        :       ANY '(' sort ')';
Maxime Perrotin's avatar
Maxime Perrotin committed
971
972
973
974
975


sort    :       sort_id
        ->      ^(SORT sort_id);

976
977
978
type_inst
        :       type_id
        ->      ^(TYPE_INSTANCE type_id);
Maxime Perrotin's avatar
Maxime Perrotin committed
979
980
981
982
983

syntype :       syntype_id;


import_expression
dbarbera's avatar
dbarbera committed
984
        :       IMPORT '(' remote_variable_id (',' destination)? ')';
Maxime Perrotin's avatar
Maxime Perrotin committed
985
986
987


view_expression
dbarbera's avatar
dbarbera committed
988
        :       VIEW '(' view_id (',' pid_expression)? ')';
Maxime Perrotin's avatar
Maxime Perrotin committed
989
990
991
992
993
994
995
996
997
998


variable_access
        :       variable_id;


operator_application
        :       operator_id '('active_expression_list ')';


dbarbera's avatar
dbarbera committed
999
active_expression_list
Maxime Perrotin's avatar
Maxime Perrotin committed
1000
1001
1002
1003
        :       active_expression (',' expression_list)?;/* |
                ground_expression ',' active_expression_list;*/   // Will not work (recursion)


1004
//synonym :       ID; // synonym_id | external_synonym;
Maxime Perrotin's avatar
Maxime Perrotin committed
1005
1006
1007
1008
1009

external_synonym
        :       external_synonym_id;


1010
conditional_expression
Maxime Perrotin's avatar
Maxime Perrotin committed
1011
1012
1013
        :       IF ifexpr=expression
                THEN thenexpr=expression
                ELSE elseexpr=expression FI
1014
        ->      ^(CONDITIONAL $ifexpr $thenexpr $elseexpr);
Maxime Perrotin's avatar
Maxime Perrotin committed
1015
1016


dbarbera's avatar
dbarbera committed
1017
expression_list
Maxime Perrotin's avatar
Maxime Perrotin committed
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
        :       expression (',' expression)*
        ->      expression+;


terminator_statement
        :       label?
                cif?
                hyperlink?
                terminator
                end
        ->      ^(TERMINATOR label? cif? hyperlink? end? terminator);

label
        :       cif? connector_name ':'
        ->      ^(LABEL cif? connector_name);


terminator
1036
        :       nextstate | join | stop | return_stmt;
Maxime Perrotin's avatar
Maxime Perrotin committed
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057


join
        :        JOIN connector_name
        ->       ^(JOIN connector_name);


stop    :       STOP;


return_stmt
        :       RETURN expression?
        ->      ^(RETURN expression?);


nextstate
        :       NEXTSTATE nextstatebody
        ->      ^(NEXTSTATE nextstatebody);


nextstatebody
1058
        :       statename via?
Maxime Perrotin's avatar
Maxime Perrotin committed
1059
1060
1061
                | dash_nextstate;


1062
1063
1064
1065
via     :       VIA state_entry_point_name
        ->      ^(VIA state_entry_point_name);


Maxime Perrotin's avatar
Maxime Perrotin committed
1066
end
1067
        :   (cif? hyperlink? COMMENT STRING)? SEMI+
1068
        -> ^(COMMENT cif? hyperlink? STRING)?;
Maxime Perrotin's avatar
Maxime Perrotin committed
1069
1070
1071
1072
1073
1074


cif
        :       cif_decl symbolname
                L_PAREN x=INT COMMA y=INT R_PAREN
                COMMA
dbarbera's avatar
dbarbera committed
1075
                L_PAREN width=INT COMMA height=INT R_PAREN
Maxime Perrotin's avatar
Maxime Perrotin committed
1076
1077
1078
1079
1080
                cif_end
        ->      ^(CIF $x $y $width $height);


hyperlink
1081
        :       cif_decl KEEP SPECIFIC GEODE HYPERLINK STRING
Maxime Perrotin's avatar
Maxime Perrotin committed
1082
                cif_end
1083
        ->      ^(HYPERLINK STRING);
Maxime Perrotin's avatar
Maxime Perrotin committed
1084
1085
1086

/* OpenGEODE specific: SDL does not allow specifying the name
   of signal parameters, but it is needed to generate function signatures
dbarbera's avatar
dbarbera committed
1087
   when generating code (in particular in Ada, where the name in the
Maxime Perrotin's avatar
Maxime Perrotin committed
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
   body must comply with the one of the source
   Extension is using CIF comment so it is invisible to other SDL parsers
   (This is valid SDL code - see ITU-T Z106)
*/
paramnames
        :       cif_decl KEEP SPECIFIC GEODE PARAMNAMES field_name+ cif_end
        ->      ^(PARAMNAMES field_name+);


/* OpenGEODE specific: Allow specifying the name of an ASN.1 file
   as a CIF extension linked to a USE clause.
   CIF Extensions are valid SDL constructs (ITU-T Z106)
*/
use_asn1
1102
1103
        :       cif_decl KEEP SPECIFIC GEODE ASNFILENAME STRING cif_end
        ->      ^(ASN1 STRING);
Maxime Perrotin's avatar
Maxime Perrotin committed
1104
1105


Maxime Perrotin's avatar
Maxime Perrotin committed
1106
1107
1108
/* OpenGEODE specific: Boolean condition that can be used in simulators
*/
stop_if
1109
1110
        :       (STOP IF expression end)+
        ->      ^(STOPIF expression+);
Maxime Perrotin's avatar
Maxime Perrotin committed
1111

Maxime Perrotin's avatar
Maxime Perrotin committed
1112
1113
1114
1115
1116
1117
symbolname
        :       START
                | INPUT
                | OUTPUT
                | STATE
                | PROCEDURE
1118
                | PROCESS
Maxime Perrotin's avatar
Maxime Perrotin committed
1119
1120
                | PROCEDURE_CALL
                | STOP
1121
                | RETURN
Maxime Perrotin's avatar
Maxime Perrotin committed
1122
1123
1124
1125
1126
1127
1128
1129
                | DECISION
                | TEXT
                | TASK
                | NEXTSTATE
                | ANSWER
                | PROVIDED
                | COMMENT
                | LABEL
Maxime Perrotin's avatar
Maxime Perrotin committed
1130
1131
                | JOIN
                | CONNECT;
Maxime Perrotin's avatar
Maxime Perrotin committed
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153


cif_decl
        :       '/* CIF';


cif_end
        :       '*/';


cif_end_text
        :       cif_decl ENDTEXT cif_end
        ->      ^(ENDTEXT);

cif_end_label
        :       cif_decl END LABEL cif_end;


dash_nextstate  :       DASH;
connector_name  :       ID;
signal_id       :       ID;
statename       :       ID;
1154
1155
state_exit_point_name
                :       ID;
1156
1157
state_entry_point_name
                :       ID;
Maxime Perrotin's avatar
Maxime Perrotin committed
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
variable_id     :       ID;
literal_id      :       ID | INT;
process_id      :       ID;
system_name     :       ID;
package_name    :       ID;
priority_signal_id
                :       ID;
signal_list_id  :       ID;
timer_id        :       ID;
field_name      :       ID;
signal_route_id :       ID;
channel_id      :       ID;
route_id        :       ID;
block_id        :       ID;
source_id       :       ID;
dest_id         :       ID;
gate_id         :       ID;
procedure_id    :       ID;
remote_procedure_id
                :       ID;
operator_id     :       ID;
synonym_id      :       ID;
external_synonym_id
                :       ID;
remote_variable_id
                :       ID;
view_id         :       ID;
sort_id         :       ID;
1186
type_id         :       ID;
Maxime Perrotin's avatar
Maxime Perrotin committed
1187
1188
syntype_id      :       ID;
stimulus_id     :       ID;
1189
ASSIG_OP        :       ':=';
Maxime Perrotin's avatar
Maxime Perrotin committed
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
L_BRACKET       :       '{';
R_BRACKET       :       '}';
L_PAREN         :       '(';
R_PAREN         :       ')';
COMMA           :       ',';
SEMI            :       ';';
DASH            :       '-';
ANY             :       A N Y;
ASTERISK        :       '*';
DCL             :       D C L;
END             :       E N D;
KEEP            :       K E E P;
PARAMNAMES      :       P A R A M N A M E S;
SPECIFIC        :       S P E C I F I C;
GEODE           :       G E O D E;
HYPERLINK       :       H Y P E R L I N K;
ENDTEXT         :       E N D T E X T;
RETURN          :       R E T U R N;
TIMER           :       T I M E R;
PROCESS         :       P R O C E S S;
ENDPROCESS      :       E N D P R O C E S S;
START           :       S T A R T;
STATE           :       S T A T E;
TEXT            :       T E X T;
PROCEDURE       :       P R O C E D U R E;
ENDPROCEDURE    :       E N D P R O C E D U R E;
PROCEDURE_CALL  :       P R O C E D U R E C A L L;
ENDSTATE        :       E N D S T A T E;
INPUT           :       I N P U T;
PROVIDED        :       P R O V I D E D;
PRIORITY        :       P R I O R I T Y;
SAVE            :       S A V E;
NONE            :       N O N E;
pid_expression
                :       S E L F
                |       P A R E N T
                |       O F F S P R I N G
                |       S E N D E R;
now_expression  :       N O W;
FOR             :       F O R;
ENDFOR          :       E N D F O R;
RANGE           :       R A N G E;
NEXTSTATE       :       N E X T S T A T E;
ANSWER          :       A N S W E R;
COMMENT         :       C O M M E N T;
LABEL           :       L A B E L;
STOP            :       S T O P;
IF              :       I F;
THEN            :       T H E N;
ELSE            :       E L S E;
FI              :       F I;
CREATE          :       C R E A T E;
OUTPUT          :       O U T P U T;
CALL            :       C A L L;
THIS            :       T H I S;
SET             :       S E T;
RESET           :       R E S E T;
ENDALTERNATIVE  :       E N D A L T E R N A T I V E;
ALTERNATIVE     :       A L T E R N A T I V E;
DECISION        :       D E C I S I O N;
ENDDECISION     :       E N D D E C I S I O N;
EXPORT          :       E X P O R T;
EXTERNAL        :       E X T E R N A L;
REFERENCED      :       R E F E R E N C E D;
CONNECTION      :       C O N N E C T I O N;
ENDCONNECTION   :       E N D C O N N E C T I O N;
FROM            :       F R O M;
TO              :       T O;
WITH            :       W I T H;
VIA             :       V I A;
ALL             :       A L L;
TASK            :       T A S K;
JOIN            :       J O I N;
PLUS            :       '+';
DOT             :       '.';
APPEND          :       '//';
IN              :       I N;
1267
OUT             :       O U T;
Maxime Perrotin's avatar
Maxime Perrotin committed
1268
INOUT           :       I N '/' O U T;
1269
1270
SUBSTRUCTURE    :       S U B S T R U C T U R E;
ENDSUBSTRUCTURE :       E N D S U B S T R U C T U R E;
Maxime Perrotin's avatar
Maxime Perrotin committed
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
FPAR            :       F P A R;
PARAM           :       P A R A M;
EQ              :       '=';
NEQ             :       '/=';
GT              :       '>';
GE              :       '>=';
LT              :        '<';
LE              :       '<=';
NOT             :       N O T;
OR              :       O R;
XOR             :       X O R;
AND             :       A N D;
IMPLIES         :       '=>';
DIV             :       '/';
MOD             :       M O D;
REM             :       R E M;
TRUE            :       T R U E;
FALSE           :       F A L S E;
ASNFILENAME     :       A S N F I L E N A M E;
NULL            :       N U L L;
PLUS_INFINITY   :       P L U S '-' I N F I N I T Y;
MINUS_INFINITY  :       M I N U S '-' I N F I N I T Y;
MANTISSA        :       M A N T I S S A;
EXPONENT        :       E X P O N E N T;
BASE            :       B A S E;
SYSTEM          :       S Y S T E M;
ENDSYSTEM       :       E N D S Y S T E M;
CHANNEL         :       C H A N N E L;
ENDCHANNEL      :       E N D C H A N N E L;
USE             :       U S E;
SIGNAL          :       S I G N A L;
BLOCK           :       B L O C K;
ENDBLOCK        :       E N D B L O C K;
SIGNALROUTE     :       S I G N A L R O U T E;
CONNECT         :       C O N N E C T;
1306
SYNTYPE         :       S Y N T Y P E;
dbarbera's avatar
dbarbera committed
1307
ENDSYNTYPE      :       E N D S Y N T Y P E;
1308
1309
NEWTYPE         :       N E W T Y P E;
ENDNEWTYPE      :       E N D N E W T Y P E;
dbarbera's avatar
dbarbera committed
1310
ARRAY           :       A R R A Y;
1311
1312
CONSTANTS       :       C O N S T A N T S;
STRUCT          :       S T R U C T;
dbarbera's avatar
dbarbera committed
1313
SYNONYM        	:       S Y N O N Y M;
dbarbera's avatar
dbarbera committed
1314
1315
1316
IMPORT          :       I M P O R T;
VIEW            :       V I E W;
ACTIVE          :       A C T I V E;
Maxime Perrotin's avatar
Maxime Perrotin committed
1317
1318
1319

fragment
STR
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
        :       '\'' ( options {greedy=false;} : .)* '\'';

STRING
        :       STR+ ;

BITSTR
        :       '"' ('0'|'1'|' ' | '\t' | '\r' | '\n')* '"B';


OCTSTR
        :       '"' ('0'..'9'|'a'..'f'|'A'..'F'|' ' | '\t' | '\r' | '\n')*
                '"H';
Maxime Perrotin's avatar
Maxime Perrotin committed
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345

ID
        :       ALPHA (ALPHA | DIGITS | '_')*;

fragment
ALPHA   :       ('a'..'z')|('A'..'Z');

INT     :       DASH? ( '0' | ('1'..'9') ('0'..'9')*);


fragment
DIGITS
        :       ('0'..'9')+;

1346
FLOAT
Maxime Perrotin's avatar
Maxime Perrotin committed
1347
1348
1349
1350
        :       INT DOT (DIGITS)? (Exponent)?
        |       INT
        ;

1351
WS  :   (' ' | '\t' | '\r' | '\n')+ {$channel=HIDDEN;};
Maxime Perrotin's avatar
Maxime Perrotin committed
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
/*
COMMENT
    :   '//' ( options {greedy=false;} : . )* '//' {$channel=HIDDEN;}
    ;
*/

fragment
Exponent : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;


COMMENT2
        :        '--' ( options {greedy=false;} : . )* ('--'|'\r'?'\n')
                 {$channel=HIDDEN;};


// Following fragments allows to have case insensitive grammar
fragment A:('a'|'A');
fragment B:('b'|'B');
fragment C:('c'|'C');
fragment D:('d'|'D');
fragment E:('e'|'E');
fragment F:('f'|'F');
fragment G:('g'|'G');
fragment H:('h'|'H');
fragment I:('i'|'I');
fragment J:('j'|'J');
fragment K:('k'|'K');
fragment L:('l'|'L');
fragment M:('m'|'M');
fragment N:('n'|'N');
fragment O:('o'|'O');
fragment P:('p'|'P');
fragment Q:('q'|'Q');
fragment R:('r'|'R');
fragment S:('s'|'S');
fragment T:('t'|'T');
fragment U:('u'|'U');
fragment V:('v'|'V');
fragment W:('w'|'W');
fragment X:('x'|'X');
fragment Y:('y'|'Y');
fragment Z:('z'|'Z');