-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsyntax_diagrams.tcl
3713 lines (3158 loc) · 81.3 KB
/
syntax_diagrams.tcl
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
912
913
914
915
916
917
918
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
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/wish
#
# Syntax diagram generator for Modula-2 (R10), status Nov 15, 2016
#
# This script is derived from the SQLite project's bubble-generator script.
# It is quite possibly the only such tool that can wrap-around diagrams so
# that they do not go off-page when inserting them into an ordinary A4 or
# US letter document. Thanks to the folks at the SQLite project for making
# their script available to the public.
#
# The present version of the script was cleaned up, enhanced, documented
# and modified by B.Kowarsch to become accessible to those unfamiliar with
# TCL/TK, and in particular to generate syntax diagrams for Modula-2 (R10).
# It is located at http://modula2.net/resources/modula2_syntax_diagrams.tcl
#
# Ideally the design would have been changed such that the script can read
# grammars from a text file in EBNF notation. Ideally, this script would
# have been rewritten in a more readable language, Modula-2 for instance.
# Due to time constraints, these tasks had to be left for some other time
# or for somebody else to do. In the meantime the documentation embedded
# herein should suffice even for those unfamiliar with TCL to modify the
# script to generate diagrams for their own grammars.
#
# THIS SOFTWARE COMES WITHOUT ANY WARRANTY OF ANY KIND. USE IS STRICTLY AT
# THE RISK OF THE USER. PERSONS WHO HAVE A LEGAL RIGHT TO SUE AUTHORS OF
# NO-WARRANTY-FREE-OF-CHARGE OPEN SOURCE SOFTWARE ARE SPECIFICALLY *NOT*
# GIVEN ANY PERMISSION TO USE THIS SOFTWARE. THE BOTTOM LINE IS : YOU MAY
# USE THIS SOFTWARE WITHOUT PERMISSION ANYWAY, BUT YOU *CANNOT* SUE THE
# AUTHORS FOR DAMAGES BECAUSE IF YOUR GOVERNMENT GRANTS YOU SUCH RIGHTS
# THEN YOU DID *NOT* HAVE PERMISSION TO USE THIS SOFTWARE TO BEGIN WITH.
# THUS, NO MATTER WHAT THE CIRCUMSTANCES, THE RISK IS ALWAYS YOURS ALONE.
#
# Top-level displays
#
toplevel .bb
canvas .c -bg white
pack .c -side top -fill both -expand 1
wm withdraw .
#
# ===========================================================================
# D O C U M E N T A T I O N
# ===========================================================================
#
# The grammar is encoded as a nested TCL list structure of the general form:
#
# { production1 { ... } production2 { ... } ... }
#
# Production rules can be translated from (ANTLR) EBNF to TCL list items as
# follows:
#
# Simple term
#
# production : term ;
# => production { line term }
#
# Sequence and group
#
# production : term1 term2 ;
# => production { line term1 term2 }
#
# Alternative
#
# production : term1 | term2 ;
# => production { or term1 term2 }
#
# Optional term
#
# production : term? ;
# => production { opt term }
# => production { optx term }
#
# opt renders the bypass line in the main path
# optx renders the term in the main path
#
# Terms that occur one or more times
#
# production : term+ ;
# => production { loop { line term } {} }
#
# Terms that occur zero or more times
#
# production : term* ;
# => production { loop {} { nil term } }
#
# Causing diagrams to wrap-around
#
# production : term1 /* wrap here */ term2 /* wrap here */ term3 ;
# => production { stack {line term1} {line term2} {line term3} }
#
# Rendering of terminals, non-terminals and tokens
#
# Symbols are rendered according to their category:
# (1) reserved words, names in all uppercase letters
# (2) reserved identifiers, names in all uppercase letters preceded by /
# (3) other terminals, mixed case names with a leading uppercase letter
# (4) non-terminals, mixed case names with a leading lowercase letter
# (5) single letter tokens, a single letter or a range eg. a..z / A..Z
# (6) special symbol tokens, any other characters or character sequences
#
# Special names for tokens that TCL cannot handle verbatim
#
# BACKSLASH is rendered as \
# SINGLE_QUOTE is rendered as '
# DOUBLE_QUOTE is rendered as "
# LEFT_BRACE is rendered as {
# RIGHT_BRACE is rendered as }
#
# Rendering parameters
#
# RES_WORD_FONT - font/size/style used to render reserved words
# RES_IDENT_FONT - font/size/style used to render reserved identifiers
# TERM_FONT - font/size/style used to render any other terminals
# NON_TERM_FONT - font/size/style used to render non-terminals
# TOKEN_FONT - font/size/style used to render tokens
# RADIUS - turn radius for arcs
# HSEP - horizontal separation
# VSEP - vertical separation
# LWIDTH -line width
#
# Pre-requisites
#
# TCL and TK need to be installed
#
# Running the script
#
# the most fool-proof method to run this script is to call the wish shell
# with the name of the script as an argument:
#
# $ wish modula2_syntax_diagrams.tcl
#
# in the window that appears, click on the top button "Draw All Diagrams"
#
# Diagrams will be written into postscript files in the working directory
#
# ===========================================================================
#
# ===========================================================================
# Modula-2 grammar
# ===========================================================================
# To reuse this diagram generator for other languages, replace the following
# section with a definition of the grammar of the target language.
#
# Do NOT add comments or blank lines within a production rule's definition!
#
# ---------------------------------------------------------------------------
# Non-Terminal Symbols
# ---------------------------------------------------------------------------
#
set non_terminals {}
# (1) Compilation Unit
lappend non_terminals compilationUnit {
or
{line definitionModule}
{line implOrPrgmModule}
{line blueprint}
}
# ------------------------
# Definition Module Syntax
# ------------------------
# (2) Definition Module
lappend non_terminals definitionModule {
stack
{line DEFINITION MODULE moduleIdent}
{line {optx [ blueprintToObey ]} {optx FOR typeToExtend} ;}
{line {loop nil import} {loop nil definition} END moduleIdent .}
}
# (2.1) Module Identifier, Blueprint Identifier, Type to Extend
lappend non_terminals moduleIdent {
line StdIdent
}
# (2.2) Blueprint to Obey
lappend non_terminals blueprintToObey {
line blueprintIdent
}
# (3) Import
lappend non_terminals import {
line {
or
{line IMPORT {loop impexLib ,}}
libGenDirective
} ;
}
# (3.1) Import/Re-Export Library
lappend non_terminals impexLib {
line libIdent {optx reExport}
}
# (3.2) Re-Export Tag
lappend non_terminals reExport {
line +
}
# (4) Library Generation Directive
lappend non_terminals libGenDirective {
line GENLIB libIdent FROM template
FOR {loop {line placeholder = replacement} ;} END
}
# (4) Library Generation Directive 2
lappend non_terminals libGenDirective2 {
stack
{line GENLIB libIdent FROM template}
{line FOR {loop {line placeholder = replacement} ;} END}
}
# (4) Library Generation Directive 3
lappend non_terminals libGenDirective3 {
line GENLIB libIdent FROM template
FOR {loop substitution ;} END
}
# (4) Library Generation Directive 4
lappend non_terminals libGenDirective4 {
stack
{line GENLIB libIdent FROM template}
{line FOR {loop substitution ;} END}
}
# (4.1) Substitution
lappend non_terminals substitution {
line placeholder = replacement
}
# (4.2) Library Identifier, Template, Placeholder
lappend non_terminals libIdent {
line StdIdent
}
# (4.3) Replacement
lappend non_terminals replacement {
or NumberLiteral StringLiteral ChevronText
}
# (5) Identifier
lappend non_terminals ident {
or StdIdent ForeignIdent
}
# (5.1) Qualified Identifier
lappend non_terminals qualident {
loop ident .
}
# (5.2) Identifier List
lappend non_terminals identList {
loop ident ,
}
# (6) Definition
lappend non_terminals definition {
line {
or
{line CONST {loop {line constDefinition ;} nil} }
{line TYPE {loop {line typeDefinition ;} nil} }
{line VAR {loop {line identList : typeIdent ;} nil} }
{line procedureHeader ;}
{line toDoList ;}
}
}
# (6.1) Type Identifier
lappend non_terminals typeIdent {
line qualident
}
# (7) Constant Definition
lappend non_terminals constDefinition {
line {optx constDefProlog}
ident = constExpression
}
# (7.1) Constant Definition Prolog
lappend non_terminals constDefProlog {
or
{line [ propertyToBindTo ]}
restrictedExport
}
# (7.2) Constant Expression
lappend non_terminals constExpression {
line expression
}
# (7.3) Restricted Export
lappend non_terminals restrictedExport {
line *
}
# (8) Type Definition
lappend non_terminals typeDefinition {
line {optx restrictedExport} ident = {or OPAQUE type}
}
# (9) Identifier List
lappend non_terminals identList {
loop ident ,
}
# (10) Type
lappend non_terminals type {
line {
or
{line aliasType}
{line derivedType}
{line immutableType}
{line subrangeType}
{line enumType}
{line setType}
{line arrayType}
{line recordType}
{line pointerType}
{line coroutineType}
{line procedureType}
}
}
# (10.1) Alias Type
lappend non_terminals aliasType {
line ALIAS OF typeIdent
}
# (10.2) Derived Type
lappend non_terminals derivedType {
line typeIdent
}
# (10.3) Immutable Type
lappend non_terminals immutableType {
line CONST typeIdent
}
# (11) Subrange Type
lappend non_terminals subrangeType {
line range OF ordinalOrScalarType
}
# (11.1) Range Expression
lappend non_terminals range {
line [ lowerBound .. upperBound ]
}
# (11.2) Lower Bound
lappend non_terminals lowerBound {
line {optx greatherThan} constExpression
}
# (11.3) Greater Than
lappend non_terminals greatherThan {
line >
}
# (11.4) Upper Bound
lappend non_terminals upperBound {
line {optx lessThan} constExpression
}
# (11.5) Less Than
lappend non_terminals lessThan {
line <
}
# (11.6) Ordinal Or Scalar Type
lappend non_terminals ordinalOrScalarType {
line typeIdent
}
# (12) Enumeration Type
lappend non_terminals enumType {
line ( {optx + enumTypeToExtend ,} identList )
}
# (12.1) Enumeration Type To Extend
lappend non_terminals enumTypeToExtend {
line enumTypeIdent
}
# (12.2) Enumeration Type Identifier
lappend non_terminals enumTypeIdent {
line typeIdent
}
# (13) Set Type
lappend non_terminals setType {
line SET OF enumTypeIdent
}
# (14) Array Type
lappend non_terminals arrayType {
line {optx BARE} ARRAY {loop valueCount ,} OF typeIdent
}
# (14.1) Value Count
lappend non_terminals valueCount {
line constExpression
}
# (15) Record Type
lappend non_terminals recordType {
line RECORD {optx ( recTypeToExtend )} {loop fieldList ;} END
}
# (15.1) Record Type To Extend
lappend non_terminals recTypeToExtend {
or typeIdent /NIL
}
# (15.3) Field List
lappend non_terminals fieldList {
line {optx restrictedExport} varOrFieldDeclaration {optx = constExpression}
}
# (16) Pointer Type
lappend non_terminals pointerType {
line POINTER TO typeIdent
}
# (17) Coroutine Type
lappend non_terminals coroutineType {
line /COROUTINE ( assocProcType )
}
# (17.1) Associated Procedure Type
lappend non_terminals assocProcType {
line typeIdent
}
# (18) Procedure Type
lappend non_terminals procedureType {
line PROCEDURE {optx ( {loop formalType ,} )} {optx : returnedType}
}
# (18.1) Formal Type
lappend non_terminals formalType {
or nonAttrFormalType attributedFormalType allocatingFormalType variadicFormalType
}
# (18.2) Returned Type
lappend non_terminals returnedType {
line typeIdent
}
# (19) Non-Attributed Formal Type
lappend non_terminals nonAttrFormalType {
or
{line {optx {optx BARE} ARRAY {optx identList} OF} typeIdent}
castingFormalType
}
# (19.1) Casting Formal Type
lappend non_terminals castingFormalType {
line /CAST {
or
{line BARE ARRAY OF /OCTET}
{line addressTypeIdent}
}
}
# (19.2) Address Type Ident
lappend non_terminals addressTypeIdent {
line {optx /UNSAFE .} /ADDRESS
}
# (20) Attributed Formal Type
lappend non_terminals attributedFormalType {
line {or CONST VAR} {or nonAttrFormalType simpleVariadicFormalType}
}
# (21) Allocating Formal Type
lappend non_terminals allocatingFormalType {
line NEW {
or
pointerTypeIdent
{line /CAST addressTypeIdent}
}
}
# (21.1) Pointer Type Identifier
lappend non_terminals pointerTypeIdent {
line typeIdent
}
# (22) Simple Variadic Formal Type
lappend non_terminals simpleVariadicFormalType {
line ARGLIST {optx reqNumOfArgs} OF nonAttrFormalType
}
# (22.1) Required Number Of Arguments
lappend non_terminals reqNumOfArgs {
line {optx greaterThan} constExpression
}
# (23) Variadic Formal Type
lappend non_terminals variadicFormalType {
line ARGLIST {optx reqNumOfArgs} OF variadicTypeDescriptor
}
# (23.1) Variadic Type Descriptor
lappend non_terminals variadicTypeDescriptor {
or
{line LBRACE {loop variadicTypeComponent ,} RBRACE}
nonAttrFormalType
}
# (23.2) Variadic Type Component
lappend non_terminals variadicTypeComponent {
line {or CONST VAR nil} nonAttrFormalType
}
# (24) Procedure Header
lappend non_terminals procedureHeader {
line PROCEDURE {optx procHeaderProlog}
procedureSignature {optx defaultArg}
}
# (24.1) Procedure Header Prolog
lappend non_terminals procHeaderProlog {
or
{line [ {or entityToBindTo /COROUTINE} ]}
restrictedExport
}
# (24.2) Default Argument
lappend non_terminals defaultArg {
line [ ident = constExprOrConstArgFuncCall ]
}
# (24.3) Constant Expression Or Constant Argument Function Call
lappend non_terminals constExprOrConstArgFuncCall {
line expression
}
# (25) Procedure Signature
lappend non_terminals procedureSignature {
line ident {optx ( {loop formalParams ;} )} {optx : returnedType}
}
# (26) Formal Parameters
lappend non_terminals formalParams {
or
{line identList : {or nonAttrFormalType variadicFormalParams}}
attributedFormalParams
allocatingFormalParams
}
# (27) Attributed Formal Parameters
lappend non_terminals attributedFormalParams {
line {or CONST VAR}
identList : {or nonAttrFormalType simpleVariadicFormalType}
}
# (28) Allocating Formal Parameters
lappend non_terminals allocatingFormalParams {
line NEW identList : {
or
pointerTypeIdent
{line /CAST addressTypeIdent}
}
}
# (29a) Variadic Formal Parameters (M2)
lappend non_terminals variadicFormalParams {
line ARGLIST {optx reqNumOfArgs} OF varArgDescriptor
}
# (29a.1) Variadic Argument Descriptor
lappend non_terminals varArgDescriptor {
or
{line LBRACE {loop varArgComponent ;} RBRACE}
nonAttrFormalType
}
# (29a.2) Variadic Argument Component
lappend non_terminals varArgComponent {
line {or CONST VAR nil} identList : nonAttrFormalType
}
# (29b) Variadic Formal Parameters (C-FFI)
lappend non_terminals variadicFormalParamsCFFI {
line ARGLIST {
or
{line OF varArgDescriptor | terminator}
{line argcRef OF varArgDescriptor}
{line [ fmtStrRef ]}
}
}
# (29b.1) Argument List Terminator
lappend non_terminals terminator {
line constQualident
}
# (29b.2) Constant Qualified Identifier
lappend non_terminals constQualident {
line qualident
}
# (29b.3) Argument Count Reference
lappend non_terminals argcRef {
line StdIdent
}
# (29b.4) Format String Reference
lappend non_terminals fmtStrRef {
line StdIdent
}
# ----------------------------------------
# Implementation and Program Module Syntax
# ----------------------------------------
# (30) Implementation or Program Module
lappend non_terminals implOrPrgmModule {
stack
{line {optx IMPLEMENTATION} MODULE moduleIdent ;}
{line {loop nil privateImport} block moduleIdent .}
}
# (31) Private Import
lappend non_terminals privateImport {
line IMPORT {loop libIdent ,} ;
}
# (32) Block
lappend non_terminals block {
line {loop nil {nil declaration nil}}
{optx BEGIN statementSequence} END
}
# (33) Declaration
lappend non_terminals declaration {
line {
or
{line ALIAS {loop {line aliasDeclaration ;} nil}}
{line CONST {loop {line ident = constExpression ;} nil}}
{line TYPE {loop {line typeDeclaration ;} nil}}
{line VAR {loop {line varOrFieldDeclaration ;} nil}}
{line procedureHeader ; block ident ;}
{line toDoList ;}
}
}
# (33.1) Alias Declaration
lappend non_terminals aliasDeclaration {
or
namedAliasDecl
wildcardAliasDecl
}
# (33.2) Named Alias Declaration
lappend non_terminals namedAliasDecl {
line aliasName {
or
{line {loop {line , aliasName} nil} = qualifiedWildcard}
{line = qualifiedName}
}
}
# (33.3) Alias Name
lappend non_terminals aliasName {
line ident
}
# (33.4) Qualified Name
lappend non_terminals qualifiedName {
line qualident
}
# (33.5) Qualified Wildcard
lappend non_terminals qualifiedWildcard {
line qualident .*
}
# (33.6) Wildcard Alias Declaration
lappend non_terminals wildcardAliasDecl {
line * = qualifiedWildcard
}
# (34) Type Declaration
lappend non_terminals typeDeclaration {
line ident = {or indeterminateType type}
}
# (34.1) Indeterminate Type
lappend non_terminals indeterminateType {
line IN RECORD {loop {line varOrFieldDeclaration ;} nil} indeterminateField END
}
# (34.2) Indeterminate Field Declaration
lappend non_terminals indeterminateField {
line + ident : BARE ARRAY discriminantFieldIdent OF typeIdent
}
# (34.3) Discriminant Field Identifier
lappend non_terminals discriminantFieldIdent {
line ident
}
# (35) Variable or Field Declaration
lappend non_terminals varOrFieldDeclaration {
line identList : {or typeIdent anonType}
}
# (35.1) Anonymous Type
lappend non_terminals anonType {
or
{line {optx BARE} ARRAY valueCount OF typeIdent}
subrangeType
procedureType
}
# (36) Statement Sequence
lappend non_terminals statementSequence {
loop statement ;
}
# (37) Statement
lappend non_terminals statement {
line {
or
emptyStatement
memMgtOperation
updateOrProcCall
returnStatement
ifStatement
caseStatement
loopStatement
whileStatement
repeatStatement
forStatement
EXIT
}
}
# (37.1) Empty Statement
lappend non_terminals emptyStatement {
line toDoList
}
# 38) TO DO List
lappend non_terminals toDoList {
line TO DO {optx trackingRef} {loop taskToDo ;} END
}
# (38.1) Tracking Reference
lappend non_terminals trackingRef {
line ( issueId , weight )
}
# (38.2) IssueId
lappend non_terminals issueId {
line wholeNumber
}
# (38.3) Whole Number
lappend non_terminals wholeNumber {
line NumberLiteral
}
# (38.4) Task To Do
lappend non_terminals taskToDo {
line description {optx , estimatedHours}
}
# (38.5) Description
lappend non_terminals description {
line StringLiteral
}
# (38.6) Weight, Estimated Hours
lappend non_terminals estimatedHours {
line constExpression
}
# (39) Memory Management Operation
lappend non_terminals memMgtOperation {
or
{line NEW designator {or {line OF initSize} {line := initValue} nil}}
{line RETAIN designator}
{line RELEASE designator}
}
# (39.1) Initial Size, Initial Value
lappend non_terminals initSize {
line expression
}
# (40) Update Or Procedure Call
lappend non_terminals updateOrProcCall {
or
{line designator {
or
{line incOrDecSuffix}
{line := expression}
{line ( expressionList )}
nil
}
}
{line COPY designator := expression}
}
# (40.1) Increment Or Decrement Suffix
lappend non_terminals incOrDecSuffix {
or
{line ++}
{line --}
}
# (41) Return Or Yield Statement
lappend non_terminals returnStatement {
line {or RETURN YIELD} {optx expression}
}
# (42) IF Statement
lappend non_terminals ifStatement {
stack
{line IF boolExpression THEN statementSequence}
{optx {loop {line ELSIF boolExpression THEN statementSequence} nil}}
{line {optx ELSE statementSequence} END}
}
# (42.1) Boolean Expression
lappend non_terminals boolExpression {
line expression
}
# (43) CASE Statement
lappend non_terminals caseStatement {
line CASE expression OF
{loop {line | case} nil} {optx ELSE statementSequence} END
}
# (43) CASE Statement 2
lappend non_terminals caseStatement2 {
stack
{line CASE expression OF {loop {line | case} nil}}
{line {optx ELSE statementSequence} END}
}
# (43.1) Case
lappend non_terminals case {
line {loop caseLabels ,} : statementSequence
}
# (43.2) Case Labels
lappend non_terminals caseLabels {
line constExpression {optx .. constExpression}
}
# (44) LOOP Statement
lappend non_terminals loopStatement {
line LOOP statementSequence END
}
# (45) WHILE Statement
lappend non_terminals whileStatement {
line WHILE boolExpression DO statementSequence END
}
# (46) REPEAT Statement
lappend non_terminals repeatStatement {
line REPEAT statementSequence UNTIL boolExpression
}
# (47) FOR Statement
lappend non_terminals forStatement {
line FOR forLoopVariants IN iterableExpr DO statementSequence END
}
# (47) FOR Statement 2
lappend non_terminals forStatement2 {
stack
{line FOR forLoopVariants IN iterableExpr}
{line DO statementSequence END}
}
# (47.1) FOR Loop Variants
lappend non_terminals forLoopVariants {
line accessor {optx ascOrDesc} {optx , value}
}
# (47.2) Accessor, Value
lappend non_terminals accessor {
line ident
}
# (47.3) Ascender Or Descender
lappend non_terminals ascOrDesc {
line incOrDecSuffix
}
# (47.4) Iterable Expression
lappend non_terminals iterableExpr {
or
{line ordinalRange OF ordinalType}
designator
}
# (47.5) Ordinal Range
lappend non_terminals ordinalRange {
line [ firstValue .. lastValue ]
}
# (47.6) First Value
lappend non_terminals firstValue {
line expression
}
# (47.7) Last Value
lappend non_terminals lastValue {
line expression
}
# (47.8) Ordinal Type
lappend non_terminals ordinalType {
line typeIdent
}
# (48) Designator
lappend non_terminals designator {
line qualident {optx designatorTail}
}
# (48.1) Designator Tail
lappend non_terminals designatorTail {
line {
loop {
line {
or
{line [ exprListOrSlice ]}
^
}
{optx {loop {line . ident} nil}}
}
}
}
# (48.2) Expression List Or Slice
lappend non_terminals exprListOrSlice {
line expression {
optx {
or
{loop {line , expression} nil}
{line .. {optx expression}}
}
}
}
# (49) Expression List
lappend non_terminals expressionList {
loop expression ,
}
# (50) Expression
lappend non_terminals expression {
line simpleExpression {optx operL1 simpleExpression}
}
# (50.1) Level-1 Operator
lappend non_terminals operL1 {
or
= # < <= > >= IN identityOp
}
# (50.2) Identity Operator
lappend non_terminals identityOp {
line ==
}
# (51) Simple Expression
lappend non_terminals simpleExpression {
or
{loop term operL2}
{line - simpleFactor}
}
# (51.1) Level-2 Operator
lappend non_terminals operL2 {
or + - OR concatOp setDiffOp
}
# (51.2) Concatenation Operator
lappend non_terminals concatOp {
line &
}