-
Notifications
You must be signed in to change notification settings - Fork 0
/
algol60.h
2861 lines (2670 loc) · 97.3 KB
/
algol60.h
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
#ifndef _GRAMMAR_H_
#define _GRAMMAR_H_ 1
#include <wchar.h>
#ifndef TRUE
#define TRUE (0==0)
#endif
#ifndef FALSE
#define FALSE (0!=0)
#endif
typedef int (*parsefn)(void);
#define LARGEST_ALT 13 // Max number of phrases in any Alt: 0 (Reserved), 1:12
#define NEGATED_PHRASE (1U<<24U)
#define GUARD_PHRASE (1U<<25U)
#define WHITESPACE_ALLOWED (1U<<26U)
#define GRAMMAR_TYPE_SHIFT 27U
#define GRAMMAR_TYPE_MASK 31U
#define BIP_TYPE (1U <<27U)
#define PHRASE_TYPE (2U <<27U)
#define SEMANTIC_TYPE (3U <<27U)
#define KEYWORD_TYPE (4U <<27U)
#define CHAR_TYPE (5U <<27U)
#define UTF32CHAR_TYPE (6U <<27U)
#define STRING_TYPE (7U <<27U)
#define UTF32STRING_TYPE (8U <<27U)
#define REGEXP_TYPE (9U <<27U)
#define OPTION_TYPE (10U <<27U)
#define COUNT_OF_ALTS (11U <<27U)
#define COUNT_OF_PHRASES (12U <<27U)
#define ALT_NUMBER (13U <<27U)
#define INDEX_MASK 0xFFFFFFU
// (We have room for types 1..31)
#define PhraseType(idx) ((((idx)>>27U)&31U))
#define BIP_BASE 0
#define PHRASE_BASE 2
#define SEMANTIC_BASE 161
#define AST_BASE 164
#define NUM_BIPS 2
#define NUM_SIMPLE_PHRASES 159
#define NUM_SEMANTIC_PHRASES 3
#define NUM_PHRASES (NUM_BIPS+NUM_SIMPLE_PHRASES+NUM_SEMANTIC_PHRASES)
#define NUM_KEYWORDS 127
#define NUM_REGEXPS 8
#define NUM_GRAMMAR 1157
#define B_EOF 0
#define B_nl 2
#define P_SS 2
#define P_SOURCE 3
#define P_semi_opt 4
#define P_MAIN_PROGRAM 5
#define P_PROGRAM_opt 6
#define P_EXTERNAL_LEVEL_OBJECTS 7
#define P_EXTERNAL_LEVEL 8
#define P_PROCTYPE_opt 9
#define P_BOOLEAN 10
#define P_PROCEDURE 11
#define P_FORMAL_PARAMS_opt 12
#define P_MORE_FP_LIST 13
#define P_FORMAL_PARAMETER 14
#define P_VALUE_opt 15
#define P_VALUE_NAMELIST 16
#define P_MORE_VALUE_NAMELIST 17
#define P_VALUE_NAME 18
#define P_COMMENT_NO_SEMI 19
#define P_COMMENT 20
#define P_COMMENTS_opt 21
#define P_MORE_COMMENTS 22
#define P_COMMENTTEXT 23
#define P_NONSEMITEXT 24
#define P_OPT_MORELINES 25
#define P_LABELS_opt 26
#define P_comment_keyword 27
#define P_assign 28
#define P_PARAMETER_TYPES_opt 29
#define P_PARAMETER_TYPE 30
#define P_PDECLN 31
#define P_DECLIST 32
#define P_MORE_DECLIST 33
#define P_LOCAL_DECLARATION 34
#define P_SWITCH_DECLS 35
#define P_MORE_SWITCH_DECLS 36
#define P_SWITCH_DECL 37
#define P_OPT_ARRAY 38
#define P_JUMP_TARGET 39
#define P_LEXPR 40
#define P_SLEXPR 41
#define P_OWN_DECLARATION 42
#define P_OWN_ARRAY_DECLN 43
#define P_LOCAL_ARRAY_DECLN 44
#define P_LOCAL_SCALAR_DECLN 45
#define P_OWN_BOUNDED_DECLIST 46
#define P_BOUNDED_DECLIST 47
#define P_MORE_OWN_BOUNDED_DECLIST 48
#define P_MORE_BOUNDED_DECLIST 49
#define P_OWN_BOUNDS_DECLARATION 50
#define P_BOUNDS_DECLARATION 51
#define P_OWN_BOUNDS_DECLIST 52
#define P_BOUNDS_DECLIST 53
#define P_MORE_OWN_BOUNDS_DECLIST 54
#define P_MORE_BOUNDS_DECLIST 55
#define P_OWN_BOUND_DEC 56
#define P_BOUND_DEC 57
#define P_COLON_WARN_COMMA 58
#define P_CONST_EXPR 59
#define P_PROCBODY 60
#define P_LOCAL_BLOCK 61
#define P_MORE_LOCAL_STATEMENTS 62
#define P_LOCAL_STATEMENT 63
#define P_CODE 64
#define P_ONOFF 65
#define P_OPT_ELSE 66
#define P_FLE 67
#define P_REST_OF_FLE 68
#define P_FORLIST 69
#define P_MORE_LHS 70
#define P_ASSIGNMENT 71
#define P_LHS 72
#define P_RHS 73
#define P_function_designator 74
#define P_ACTUAL_PARAMETERS 75
#define P_MORE_ACTUAL_PARAMETERS 76
#define P_FPSEP 77
#define P_ACTUAL_PARAMETER 78
#define P_OPERAND 79
#define P_ARRAY_INDEX 80
#define P_ARRAY_INDICES 81
#define P_primary 82
#define P_exp_op 83
#define P_exp_factor 84
#define P_factor 85
#define P_mul_op 86
#define P_rdiv_op 87
#define P_idiv_op 88
#define P_div_op 89
#define P_muldiv_op 90
#define P_mul_factor 91
#define P_term 92
#define P_add_op 93
#define P_sub_op 94
#define P_addsub_op 95
#define P_add_term 96
#define P_simple_arithmetic_expression 97
#define P_arithmetic_expression 98
#define P_INTEGER_CONSTANT 99
#define P_REAL_CONSTANT 100
#define P_unsigned 101
#define P_decfract 102
#define P_decimalpoint 103
#define P_expart 104
#define P_decnum 105
#define P_subten 106
#define P_PLUS_MINUS_opt 107
#define P_logical_value 108
#define P_relational_operator 109
#define P_ARRAY_LB 110
#define P_ARRAY_RB 111
#define P_relation 112
#define P_Boolean_primary 113
#define P_not_term 114
#define P_not_terms 115
#define P_Boolean_secondary 116
#define P_and_term 117
#define P_and_Boolean_factor 118
#define P_Boolean_factor 119
#define P_or_term 120
#define P_or_Boolean_term 121
#define P_Boolean_term 122
#define P_impl_term 123
#define P_more_implication_Boolean 124
#define P_implication_Boolean 125
#define P_equiv_term 126
#define P_equiv_simple_Boolean 127
#define P_simple_Boolean 128
#define P_Boolean_expression 129
#define P_ch 130
#define P_stropped 131
#define P_NAME 132
#define P_ALPHANUMS 133
#define P_ALPHA 134
#define P_ALPHANUM 135
#define P_DIGITS 136
#define P_DIGIT 137
#define P_MORE_DIGITS 138
#define P_string_literal 139
#define P_dchs 140
#define P_dch 141
#define P_ldquo 142
#define P_rdquo 143
#define P_BALANCED_STRING 144
#define P_BALANCED_CHAR_SEQUENCE 145
#define P_BALANCED_CHAR 146
#define P_RB 147
#define P_C_STRING 148
#define P_C_CHARS 149
#define P_dquote 150
#define P_closer 151
#define P_semi 152
#define P_comma 153
#define P_rb 154
#define P_end 155
#define P_else 156
#define P_then 157
#define P_ENDTEXT 158
#define P_stropped_keywords 159
#define P_optional_stropping_conversion 160
#define S_init 0
#define S_terminate 1
#define S_convert_keywords 2
extern const int bip_map[NUM_BIPS];
extern const int sequential_phrase_no_to_grammar_index[NUM_SIMPLE_PHRASES];
extern const wchar_t *phrasename[NUM_BIPS+NUM_SIMPLE_PHRASES+NUM_SEMANTIC_PHRASES];
extern const wchar_t *semantic_phrasename[NUM_SEMANTIC_PHRASES];
extern const wchar_t *semantic_code[NUM_SEMANTIC_PHRASES];
extern const wchar_t *xcomment[NUM_PHRASES];
extern const wchar_t *keyword[NUM_KEYWORDS];
extern const wchar_t *regexps[NUM_REGEXPS];
extern const int gram[NUM_GRAMMAR];
#define G_SS 0
#define G_SOURCE 6
#define G_semi_opt 14
#define G_MAIN_PROGRAM 18
#define G_PROGRAM_opt 26
#define G_EXTERNAL_LEVEL_OBJECTS 32
#define G_EXTERNAL_LEVEL 37
#define G_PROCTYPE_opt 52
#define G_BOOLEAN 60
#define G_PROCEDURE 65
#define G_FORMAL_PARAMS_opt 77
#define G_MORE_FP_LIST 84
#define G_FORMAL_PARAMETER 90
#define G_VALUE_opt 93
#define G_VALUE_NAMELIST 99
#define G_MORE_VALUE_NAMELIST 103
#define G_VALUE_NAME 108
#define G_COMMENT_NO_SEMI 111
#define G_COMMENT 115
#define G_COMMENTS_opt 119
#define G_MORE_COMMENTS 124
#define G_COMMENTTEXT 130
#define G_NONSEMITEXT 134
#define G_OPT_MORELINES 137
#define G_LABELS_opt 143
#define G_comment_keyword 151
#define G_assign 154
#define G_PARAMETER_TYPES_opt 157
#define G_PARAMETER_TYPE 163
#define G_PDECLN 186
#define G_DECLIST 195
#define G_MORE_DECLIST 199
#define G_LOCAL_DECLARATION 205
#define G_SWITCH_DECLS 231
#define G_MORE_SWITCH_DECLS 235
#define G_SWITCH_DECL 241
#define G_OPT_ARRAY 251
#define G_JUMP_TARGET 257
#define G_LEXPR 260
#define G_SLEXPR 274
#define G_OWN_DECLARATION 282
#define G_OWN_ARRAY_DECLN 310
#define G_LOCAL_ARRAY_DECLN 314
#define G_LOCAL_SCALAR_DECLN 318
#define G_OWN_BOUNDED_DECLIST 321
#define G_BOUNDED_DECLIST 326
#define G_MORE_OWN_BOUNDED_DECLIST 331
#define G_MORE_BOUNDED_DECLIST 338
#define G_OWN_BOUNDS_DECLARATION 345
#define G_BOUNDS_DECLARATION 350
#define G_OWN_BOUNDS_DECLIST 355
#define G_BOUNDS_DECLIST 359
#define G_MORE_OWN_BOUNDS_DECLIST 363
#define G_MORE_BOUNDS_DECLIST 369
#define G_OWN_BOUND_DEC 375
#define G_BOUND_DEC 380
#define G_COLON_WARN_COMMA 385
#define G_CONST_EXPR 392
#define G_PROCBODY 395
#define G_LOCAL_BLOCK 435
#define G_MORE_LOCAL_STATEMENTS 441
#define G_LOCAL_STATEMENT 448
#define G_CODE 489
#define G_ONOFF 493
#define G_OPT_ELSE 498
#define G_FLE 513
#define G_REST_OF_FLE 517
#define G_FORLIST 527
#define G_MORE_LHS 533
#define G_ASSIGNMENT 540
#define G_LHS 547
#define G_RHS 556
#define G_function_designator 563
#define G_ACTUAL_PARAMETERS 569
#define G_MORE_ACTUAL_PARAMETERS 575
#define G_FPSEP 581
#define G_ACTUAL_PARAMETER 589
#define G_OPERAND 598
#define G_ARRAY_INDEX 615
#define G_ARRAY_INDICES 618
#define G_primary 624
#define G_exp_op 628
#define G_exp_factor 639
#define G_factor 644
#define G_mul_op 648
#define G_rdiv_op 653
#define G_idiv_op 656
#define G_div_op 667
#define G_muldiv_op 672
#define G_mul_factor 677
#define G_term 682
#define G_add_op 686
#define G_sub_op 689
#define G_addsub_op 692
#define G_add_term 697
#define G_simple_arithmetic_expression 702
#define G_arithmetic_expression 706
#define G_INTEGER_CONSTANT 716
#define G_REAL_CONSTANT 720
#define G_unsigned 724
#define G_decfract 732
#define G_decimalpoint 736
#define G_expart 741
#define G_decnum 745
#define G_subten 753
#define G_PLUS_MINUS_opt 766
#define G_logical_value 774
#define G_relational_operator 779
#define G_ARRAY_LB 838
#define G_ARRAY_RB 843
#define G_relation 848
#define G_Boolean_primary 853
#define G_not_term 872
#define G_not_terms 881
#define G_Boolean_secondary 886
#define G_and_term 893
#define G_and_Boolean_factor 900
#define G_Boolean_factor 905
#define G_or_term 909
#define G_or_Boolean_term 914
#define G_Boolean_term 919
#define G_impl_term 923
#define G_more_implication_Boolean 936
#define G_implication_Boolean 941
#define G_equiv_term 945
#define G_equiv_simple_Boolean 954
#define G_simple_Boolean 959
#define G_Boolean_expression 963
#define G_ch 973
#define G_stropped 978
#define G_NAME 981
#define G_ALPHANUMS 985
#define G_ALPHA 990
#define G_ALPHANUM 994
#define G_DIGITS 998
#define G_DIGIT 1002
#define G_MORE_DIGITS 1005
#define G_string_literal 1010
#define G_dchs 1015
#define G_dch 1020
#define G_ldquo 1024
#define G_rdquo 1041
#define G_BALANCED_STRING 1058
#define G_BALANCED_CHAR_SEQUENCE 1063
#define G_BALANCED_CHAR 1068
#define G_RB 1074
#define G_C_STRING 1077
#define G_C_CHARS 1090
#define G_dquote 1107
#define G_closer 1110
#define G_semi 1123
#define G_comma 1126
#define G_rb 1129
#define G_end 1132
#define G_else 1135
#define G_then 1138
#define G_ENDTEXT 1141
#define G_stropped_keywords 1149
#define G_optional_stropping_conversion 1152
extern parsefn parsetime[NUM_SEMANTIC_PHRASES];
extern int parse_init(void);
extern int parse_terminate(void);
extern int parse_convert_keywords(void);
#ifndef SUPPRESS_DATA
const wchar_t *phrasename[NUM_BIPS+NUM_SIMPLE_PHRASES+NUM_SEMANTIC_PHRASES] = {
/*0+0*/ L"EOF" /*0*/,
/*0+1*/ L"nl" /*2*/,
/*2+0*/ L"SS",
/*2+1*/ L"SOURCE",
/*2+2*/ L"semi_opt",
/*2+3*/ L"MAIN-PROGRAM",
/*2+4*/ L"PROGRAM_opt",
/*2+5*/ L"EXTERNAL-LEVEL-OBJECTS",
/*2+6*/ L"EXTERNAL-LEVEL",
/*2+7*/ L"PROCTYPE_opt",
/*2+8*/ L"BOOLEAN",
/*2+9*/ L"PROCEDURE",
/*2+10*/ L"FORMAL_PARAMS_opt",
/*2+11*/ L"MORE-FP-LIST",
/*2+12*/ L"FORMAL-PARAMETER",
/*2+13*/ L"VALUE_opt",
/*2+14*/ L"VALUE-NAMELIST",
/*2+15*/ L"MORE-VALUE-NAMELIST",
/*2+16*/ L"VALUE-NAME",
/*2+17*/ L"COMMENT-NO-SEMI",
/*2+18*/ L"COMMENT",
/*2+19*/ L"COMMENTS_opt",
/*2+20*/ L"MORE-COMMENTS",
/*2+21*/ L"COMMENTTEXT",
/*2+22*/ L"NONSEMITEXT",
/*2+23*/ L"OPT-MORELINES",
/*2+24*/ L"LABELS_opt",
/*2+25*/ L"comment-keyword",
/*2+26*/ L"assign",
/*2+27*/ L"PARAMETER-TYPES_opt",
/*2+28*/ L"PARAMETER-TYPE",
/*2+29*/ L"PDECLN",
/*2+30*/ L"DECLIST",
/*2+31*/ L"MORE-DECLIST",
/*2+32*/ L"LOCAL-DECLARATION",
/*2+33*/ L"SWITCH-DECLS",
/*2+34*/ L"MORE-SWITCH-DECLS",
/*2+35*/ L"SWITCH-DECL",
/*2+36*/ L"OPT-ARRAY",
/*2+37*/ L"JUMP-TARGET",
/*2+38*/ L"LEXPR",
/*2+39*/ L"SLEXPR",
/*2+40*/ L"OWN-DECLARATION",
/*2+41*/ L"OWN-ARRAY-DECLN",
/*2+42*/ L"LOCAL-ARRAY-DECLN",
/*2+43*/ L"LOCAL-SCALAR-DECLN",
/*2+44*/ L"OWN-BOUNDED-DECLIST",
/*2+45*/ L"BOUNDED-DECLIST",
/*2+46*/ L"MORE-OWN-BOUNDED-DECLIST",
/*2+47*/ L"MORE-BOUNDED-DECLIST",
/*2+48*/ L"OWN-BOUNDS-DECLARATION",
/*2+49*/ L"BOUNDS-DECLARATION",
/*2+50*/ L"OWN-BOUNDS-DECLIST",
/*2+51*/ L"BOUNDS-DECLIST",
/*2+52*/ L"MORE-OWN-BOUNDS-DECLIST",
/*2+53*/ L"MORE-BOUNDS-DECLIST",
/*2+54*/ L"OWN-BOUND-DEC",
/*2+55*/ L"BOUND-DEC",
/*2+56*/ L"COLON-WARN-COMMA",
/*2+57*/ L"CONST-EXPR",
/*2+58*/ L"PROCBODY",
/*2+59*/ L"LOCAL-BLOCK",
/*2+60*/ L"MORE-LOCAL-STATEMENTS",
/*2+61*/ L"LOCAL-STATEMENT",
/*2+62*/ L"CODE",
/*2+63*/ L"ONOFF",
/*2+64*/ L"OPT-ELSE",
/*2+65*/ L"FLE",
/*2+66*/ L"REST-OF-FLE",
/*2+67*/ L"FORLIST",
/*2+68*/ L"MORE-LHS",
/*2+69*/ L"ASSIGNMENT",
/*2+70*/ L"LHS",
/*2+71*/ L"RHS",
/*2+72*/ L"function_designator",
/*2+73*/ L"ACTUAL-PARAMETERS",
/*2+74*/ L"MORE-ACTUAL-PARAMETERS",
/*2+75*/ L"FPSEP",
/*2+76*/ L"ACTUAL-PARAMETER",
/*2+77*/ L"OPERAND",
/*2+78*/ L"ARRAY-INDEX",
/*2+79*/ L"ARRAY-INDICES",
/*2+80*/ L"primary",
/*2+81*/ L"exp-op",
/*2+82*/ L"exp-factor",
/*2+83*/ L"factor",
/*2+84*/ L"mul-op",
/*2+85*/ L"rdiv-op",
/*2+86*/ L"idiv-op",
/*2+87*/ L"div-op",
/*2+88*/ L"muldiv-op",
/*2+89*/ L"mul-factor",
/*2+90*/ L"term",
/*2+91*/ L"add-op",
/*2+92*/ L"sub-op",
/*2+93*/ L"addsub-op",
/*2+94*/ L"add-term",
/*2+95*/ L"simple_arithmetic_expression",
/*2+96*/ L"arithmetic_expression",
/*2+97*/ L"INTEGER-CONSTANT",
/*2+98*/ L"REAL-CONSTANT",
/*2+99*/ L"unsigned",
/*2+100*/ L"decfract",
/*2+101*/ L"decimalpoint",
/*2+102*/ L"expart",
/*2+103*/ L"decnum",
/*2+104*/ L"subten",
/*2+105*/ L"PLUS-MINUS-opt",
/*2+106*/ L"logical_value",
/*2+107*/ L"relational_operator",
/*2+108*/ L"ARRAY-LB",
/*2+109*/ L"ARRAY-RB",
/*2+110*/ L"relation",
/*2+111*/ L"Boolean_primary",
/*2+112*/ L"not-term",
/*2+113*/ L"not-terms",
/*2+114*/ L"Boolean_secondary",
/*2+115*/ L"and-term",
/*2+116*/ L"and_Boolean_factor",
/*2+117*/ L"Boolean_factor",
/*2+118*/ L"or-term",
/*2+119*/ L"or_Boolean_term",
/*2+120*/ L"Boolean_term",
/*2+121*/ L"impl-term",
/*2+122*/ L"more_implication_Boolean",
/*2+123*/ L"implication_Boolean",
/*2+124*/ L"equiv-term",
/*2+125*/ L"equiv_simple_Boolean",
/*2+126*/ L"simple_Boolean",
/*2+127*/ L"Boolean_expression",
/*2+128*/ L"ch",
/*2+129*/ L"stropped",
/*2+130*/ L"NAME",
/*2+131*/ L"ALPHANUMS",
/*2+132*/ L"ALPHA",
/*2+133*/ L"ALPHANUM",
/*2+134*/ L"DIGITS",
/*2+135*/ L"DIGIT",
/*2+136*/ L"MORE-DIGITS",
/*2+137*/ L"string_literal",
/*2+138*/ L"dchs",
/*2+139*/ L"dch",
/*2+140*/ L"ldquo",
/*2+141*/ L"rdquo",
/*2+142*/ L"BALANCED-STRING",
/*2+143*/ L"BALANCED-CHAR-SEQUENCE",
/*2+144*/ L"BALANCED-CHAR",
/*2+145*/ L"RB",
/*2+146*/ L"C-STRING",
/*2+147*/ L"C-CHARS",
/*2+148*/ L"dquote",
/*2+149*/ L"closer",
/*2+150*/ L"semi",
/*2+151*/ L"comma",
/*2+152*/ L"rb",
/*2+153*/ L"end",
/*2+154*/ L"else",
/*2+155*/ L"then",
/*2+156*/ L"ENDTEXT",
/*2+157*/ L"stropped-keywords",
/*2+158*/ L"optional-stropping-conversion",
/*161+0*/ L"init",
/*161+1*/ L"terminate",
/*161+2*/ L"convert-keywords",
};
const wchar_t *phrasename_c[NUM_BIPS+NUM_SIMPLE_PHRASES+NUM_SEMANTIC_PHRASES] = {
/*0+0*/ L"EOF" /*0*/,
/*0+1*/ L"nl" /*2*/,
/*2+0*/ L"SS",
/*2+1*/ L"SOURCE",
/*2+2*/ L"semi_opt",
/*2+3*/ L"MAIN_PROGRAM",
/*2+4*/ L"PROGRAM_opt",
/*2+5*/ L"EXTERNAL_LEVEL_OBJECTS",
/*2+6*/ L"EXTERNAL_LEVEL",
/*2+7*/ L"PROCTYPE_opt",
/*2+8*/ L"BOOLEAN",
/*2+9*/ L"PROCEDURE",
/*2+10*/ L"FORMAL_PARAMS_opt",
/*2+11*/ L"MORE_FP_LIST",
/*2+12*/ L"FORMAL_PARAMETER",
/*2+13*/ L"VALUE_opt",
/*2+14*/ L"VALUE_NAMELIST",
/*2+15*/ L"MORE_VALUE_NAMELIST",
/*2+16*/ L"VALUE_NAME",
/*2+17*/ L"COMMENT_NO_SEMI",
/*2+18*/ L"COMMENT",
/*2+19*/ L"COMMENTS_opt",
/*2+20*/ L"MORE_COMMENTS",
/*2+21*/ L"COMMENTTEXT",
/*2+22*/ L"NONSEMITEXT",
/*2+23*/ L"OPT_MORELINES",
/*2+24*/ L"LABELS_opt",
/*2+25*/ L"comment_keyword",
/*2+26*/ L"assign",
/*2+27*/ L"PARAMETER_TYPES_opt",
/*2+28*/ L"PARAMETER_TYPE",
/*2+29*/ L"PDECLN",
/*2+30*/ L"DECLIST",
/*2+31*/ L"MORE_DECLIST",
/*2+32*/ L"LOCAL_DECLARATION",
/*2+33*/ L"SWITCH_DECLS",
/*2+34*/ L"MORE_SWITCH_DECLS",
/*2+35*/ L"SWITCH_DECL",
/*2+36*/ L"OPT_ARRAY",
/*2+37*/ L"JUMP_TARGET",
/*2+38*/ L"LEXPR",
/*2+39*/ L"SLEXPR",
/*2+40*/ L"OWN_DECLARATION",
/*2+41*/ L"OWN_ARRAY_DECLN",
/*2+42*/ L"LOCAL_ARRAY_DECLN",
/*2+43*/ L"LOCAL_SCALAR_DECLN",
/*2+44*/ L"OWN_BOUNDED_DECLIST",
/*2+45*/ L"BOUNDED_DECLIST",
/*2+46*/ L"MORE_OWN_BOUNDED_DECLIST",
/*2+47*/ L"MORE_BOUNDED_DECLIST",
/*2+48*/ L"OWN_BOUNDS_DECLARATION",
/*2+49*/ L"BOUNDS_DECLARATION",
/*2+50*/ L"OWN_BOUNDS_DECLIST",
/*2+51*/ L"BOUNDS_DECLIST",
/*2+52*/ L"MORE_OWN_BOUNDS_DECLIST",
/*2+53*/ L"MORE_BOUNDS_DECLIST",
/*2+54*/ L"OWN_BOUND_DEC",
/*2+55*/ L"BOUND_DEC",
/*2+56*/ L"COLON_WARN_COMMA",
/*2+57*/ L"CONST_EXPR",
/*2+58*/ L"PROCBODY",
/*2+59*/ L"LOCAL_BLOCK",
/*2+60*/ L"MORE_LOCAL_STATEMENTS",
/*2+61*/ L"LOCAL_STATEMENT",
/*2+62*/ L"CODE",
/*2+63*/ L"ONOFF",
/*2+64*/ L"OPT_ELSE",
/*2+65*/ L"FLE",
/*2+66*/ L"REST_OF_FLE",
/*2+67*/ L"FORLIST",
/*2+68*/ L"MORE_LHS",
/*2+69*/ L"ASSIGNMENT",
/*2+70*/ L"LHS",
/*2+71*/ L"RHS",
/*2+72*/ L"function_designator",
/*2+73*/ L"ACTUAL_PARAMETERS",
/*2+74*/ L"MORE_ACTUAL_PARAMETERS",
/*2+75*/ L"FPSEP",
/*2+76*/ L"ACTUAL_PARAMETER",
/*2+77*/ L"OPERAND",
/*2+78*/ L"ARRAY_INDEX",
/*2+79*/ L"ARRAY_INDICES",
/*2+80*/ L"primary",
/*2+81*/ L"exp_op",
/*2+82*/ L"exp_factor",
/*2+83*/ L"factor",
/*2+84*/ L"mul_op",
/*2+85*/ L"rdiv_op",
/*2+86*/ L"idiv_op",
/*2+87*/ L"div_op",
/*2+88*/ L"muldiv_op",
/*2+89*/ L"mul_factor",
/*2+90*/ L"term",
/*2+91*/ L"add_op",
/*2+92*/ L"sub_op",
/*2+93*/ L"addsub_op",
/*2+94*/ L"add_term",
/*2+95*/ L"simple_arithmetic_expression",
/*2+96*/ L"arithmetic_expression",
/*2+97*/ L"INTEGER_CONSTANT",
/*2+98*/ L"REAL_CONSTANT",
/*2+99*/ L"unsigned",
/*2+100*/ L"decfract",
/*2+101*/ L"decimalpoint",
/*2+102*/ L"expart",
/*2+103*/ L"decnum",
/*2+104*/ L"subten",
/*2+105*/ L"PLUS_MINUS_opt",
/*2+106*/ L"logical_value",
/*2+107*/ L"relational_operator",
/*2+108*/ L"ARRAY_LB",
/*2+109*/ L"ARRAY_RB",
/*2+110*/ L"relation",
/*2+111*/ L"Boolean_primary",
/*2+112*/ L"not_term",
/*2+113*/ L"not_terms",
/*2+114*/ L"Boolean_secondary",
/*2+115*/ L"and_term",
/*2+116*/ L"and_Boolean_factor",
/*2+117*/ L"Boolean_factor",
/*2+118*/ L"or_term",
/*2+119*/ L"or_Boolean_term",
/*2+120*/ L"Boolean_term",
/*2+121*/ L"impl_term",
/*2+122*/ L"more_implication_Boolean",
/*2+123*/ L"implication_Boolean",
/*2+124*/ L"equiv_term",
/*2+125*/ L"equiv_simple_Boolean",
/*2+126*/ L"simple_Boolean",
/*2+127*/ L"Boolean_expression",
/*2+128*/ L"ch",
/*2+129*/ L"stropped",
/*2+130*/ L"NAME",
/*2+131*/ L"ALPHANUMS",
/*2+132*/ L"ALPHA",
/*2+133*/ L"ALPHANUM",
/*2+134*/ L"DIGITS",
/*2+135*/ L"DIGIT",
/*2+136*/ L"MORE_DIGITS",
/*2+137*/ L"string_literal",
/*2+138*/ L"dchs",
/*2+139*/ L"dch",
/*2+140*/ L"ldquo",
/*2+141*/ L"rdquo",
/*2+142*/ L"BALANCED_STRING",
/*2+143*/ L"BALANCED_CHAR_SEQUENCE",
/*2+144*/ L"BALANCED_CHAR",
/*2+145*/ L"RB",
/*2+146*/ L"C_STRING",
/*2+147*/ L"C_CHARS",
/*2+148*/ L"dquote",
/*2+149*/ L"closer",
/*2+150*/ L"semi",
/*2+151*/ L"comma",
/*2+152*/ L"rb",
/*2+153*/ L"end",
/*2+154*/ L"else",
/*2+155*/ L"then",
/*2+156*/ L"ENDTEXT",
/*2+157*/ L"stropped_keywords",
/*2+158*/ L"optional_stropping_conversion",
/*161+0*/ L"init",
/*161+1*/ L"terminate",
/*161+2*/ L"convert_keywords",
};
const int bip_map[NUM_BIPS] = {
/*0*/ 0,
/*1*/ 2,
};
const int sequential_phrase_no_to_grammar_index[NUM_SIMPLE_PHRASES] = {
G_SS, /*0*/
G_SOURCE, /*6*/
G_semi_opt, /*14*/
G_MAIN_PROGRAM, /*18*/
G_PROGRAM_opt, /*26*/
G_EXTERNAL_LEVEL_OBJECTS, /*32*/
G_EXTERNAL_LEVEL, /*37*/
G_PROCTYPE_opt, /*52*/
G_BOOLEAN, /*60*/
G_PROCEDURE, /*65*/
G_FORMAL_PARAMS_opt, /*77*/
G_MORE_FP_LIST, /*84*/
G_FORMAL_PARAMETER, /*90*/
G_VALUE_opt, /*93*/
G_VALUE_NAMELIST, /*99*/
G_MORE_VALUE_NAMELIST, /*103*/
G_VALUE_NAME, /*108*/
G_COMMENT_NO_SEMI, /*111*/
G_COMMENT, /*115*/
G_COMMENTS_opt, /*119*/
G_MORE_COMMENTS, /*124*/
G_COMMENTTEXT, /*130*/
G_NONSEMITEXT, /*134*/
G_OPT_MORELINES, /*137*/
G_LABELS_opt, /*143*/
G_comment_keyword, /*151*/
G_assign, /*154*/
G_PARAMETER_TYPES_opt, /*157*/
G_PARAMETER_TYPE, /*163*/
G_PDECLN, /*186*/
G_DECLIST, /*195*/
G_MORE_DECLIST, /*199*/
G_LOCAL_DECLARATION, /*205*/
G_SWITCH_DECLS, /*231*/
G_MORE_SWITCH_DECLS, /*235*/
G_SWITCH_DECL, /*241*/
G_OPT_ARRAY, /*251*/
G_JUMP_TARGET, /*257*/
G_LEXPR, /*260*/
G_SLEXPR, /*274*/
G_OWN_DECLARATION, /*282*/
G_OWN_ARRAY_DECLN, /*310*/
G_LOCAL_ARRAY_DECLN, /*314*/
G_LOCAL_SCALAR_DECLN, /*318*/
G_OWN_BOUNDED_DECLIST, /*321*/
G_BOUNDED_DECLIST, /*326*/
G_MORE_OWN_BOUNDED_DECLIST, /*331*/
G_MORE_BOUNDED_DECLIST, /*338*/
G_OWN_BOUNDS_DECLARATION, /*345*/
G_BOUNDS_DECLARATION, /*350*/
G_OWN_BOUNDS_DECLIST, /*355*/
G_BOUNDS_DECLIST, /*359*/
G_MORE_OWN_BOUNDS_DECLIST, /*363*/
G_MORE_BOUNDS_DECLIST, /*369*/
G_OWN_BOUND_DEC, /*375*/
G_BOUND_DEC, /*380*/
G_COLON_WARN_COMMA, /*385*/
G_CONST_EXPR, /*392*/
G_PROCBODY, /*395*/
G_LOCAL_BLOCK, /*435*/
G_MORE_LOCAL_STATEMENTS, /*441*/
G_LOCAL_STATEMENT, /*448*/
G_CODE, /*489*/
G_ONOFF, /*493*/
G_OPT_ELSE, /*498*/
G_FLE, /*513*/
G_REST_OF_FLE, /*517*/
G_FORLIST, /*527*/
G_MORE_LHS, /*533*/
G_ASSIGNMENT, /*540*/
G_LHS, /*547*/
G_RHS, /*556*/
G_function_designator, /*563*/
G_ACTUAL_PARAMETERS, /*569*/
G_MORE_ACTUAL_PARAMETERS, /*575*/
G_FPSEP, /*581*/
G_ACTUAL_PARAMETER, /*589*/
G_OPERAND, /*598*/
G_ARRAY_INDEX, /*615*/
G_ARRAY_INDICES, /*618*/
G_primary, /*624*/
G_exp_op, /*628*/
G_exp_factor, /*639*/
G_factor, /*644*/
G_mul_op, /*648*/
G_rdiv_op, /*653*/
G_idiv_op, /*656*/
G_div_op, /*667*/
G_muldiv_op, /*672*/
G_mul_factor, /*677*/
G_term, /*682*/
G_add_op, /*686*/
G_sub_op, /*689*/
G_addsub_op, /*692*/
G_add_term, /*697*/
G_simple_arithmetic_expression, /*702*/
G_arithmetic_expression, /*706*/
G_INTEGER_CONSTANT, /*716*/
G_REAL_CONSTANT, /*720*/
G_unsigned, /*724*/
G_decfract, /*732*/
G_decimalpoint, /*736*/
G_expart, /*741*/
G_decnum, /*745*/
G_subten, /*753*/
G_PLUS_MINUS_opt, /*766*/
G_logical_value, /*774*/
G_relational_operator, /*779*/
G_ARRAY_LB, /*838*/
G_ARRAY_RB, /*843*/
G_relation, /*848*/
G_Boolean_primary, /*853*/
G_not_term, /*872*/
G_not_terms, /*881*/
G_Boolean_secondary, /*886*/
G_and_term, /*893*/
G_and_Boolean_factor, /*900*/
G_Boolean_factor, /*905*/
G_or_term, /*909*/
G_or_Boolean_term, /*914*/
G_Boolean_term, /*919*/
G_impl_term, /*923*/
G_more_implication_Boolean, /*936*/
G_implication_Boolean, /*941*/
G_equiv_term, /*945*/
G_equiv_simple_Boolean, /*954*/
G_simple_Boolean, /*959*/
G_Boolean_expression, /*963*/
G_ch, /*973*/
G_stropped, /*978*/
G_NAME, /*981*/
G_ALPHANUMS, /*985*/
G_ALPHA, /*990*/
G_ALPHANUM, /*994*/
G_DIGITS, /*998*/
G_DIGIT, /*1002*/
G_MORE_DIGITS, /*1005*/
G_string_literal, /*1010*/
G_dchs, /*1015*/
G_dch, /*1020*/
G_ldquo, /*1024*/
G_rdquo, /*1041*/
G_BALANCED_STRING, /*1058*/
G_BALANCED_CHAR_SEQUENCE, /*1063*/
G_BALANCED_CHAR, /*1068*/
G_RB, /*1074*/
G_C_STRING, /*1077*/
G_C_CHARS, /*1090*/
G_dquote, /*1107*/
G_closer, /*1110*/
G_semi, /*1123*/
G_comma, /*1126*/
G_rb, /*1129*/
G_end, /*1132*/
G_else, /*1135*/
G_then, /*1138*/
G_ENDTEXT, /*1141*/
G_stropped_keywords, /*1149*/
G_optional_stropping_conversion, /*1152*/
};
const wchar_t *semantic_phrasename[NUM_SEMANTIC_PHRASES] = {
/*0*/ L"init",
/*1*/ L"terminate",
/*2*/ L"convert-keywords",
};
const wchar_t *semantic_code[NUM_SEMANTIC_PHRASES] = {
/*0*/ L"\n"
" // peform any initialisation required by the parse-time semantic routines.\n"
" // Note that for now, we have no way of declaring data outside of\n"
" // those procedures. Obviously this will have to change.\n"
" return TRUE;\n",
/*1*/ L"\n"
" // perform any final tidy-up required by the parse-time semantic routines.\n"
" return TRUE;\n",
/*2*/ L"\n"
"#ifdef IN_PARSER\n"
" int debug_stropping = 0;\n"
"\n"
" // Loop through the source() array and convert 'stropped' keywords into u̲n̲d̲e̲r̲l̲i̲n̲e̲d̲ keywords.\n"
" // This draft version unfortunately *will* convert stropped words in strings and comments.\n"
" // - see tests/cacm/101.a60 for examples...\n"
" // Will try to fix later although the syntax of comments at the end of a procedure block\n"
" // means that a simple lexical filter may just not be possible.\n"
"\n"
" int FP = 0, PP = 0;\n"
"\n"
" // AN EXTRA ARRAY IS NEEDED HERE BECAUSE THE STROPPING ADDS AN EXTRA\n"
" // CHARACTER *PER LETTER* AND OVERWRITES THE INPUT AT FP! These extra\n"
" // characters are not compensated for by the removal of the two quotes.\n"
" // It would be so much nicer if we had a single Unicode character representing\n"
" // a stropped letter. Would solve a nasty lexing problem as well as this.\n"
"\n"
" DECLARE(stropped_source, wint_t, 600000); \n"
" #define _stropped_source(x) WRITE(x,stropped_source,wint_t)\n"
" #define stropped_source(x) READ(x,stropped_source,wint_t)\n"
"\n"
" for (;;) {\n"
" wint_t WC = source(FP++);\n"
" if (WC == '\\'') {\n"
" int Peek = FP;\n"
" while (isalpha(source(Peek))) { Peek += 1; };\n"
" if (source(Peek) == '\\'') {\n"
" // We have 'KEYWORD'\n"
" // opening ' skipped already\n"
" while (isalpha(source(FP))) {\n"
" WC = source(FP++);\n"
" if (isupper(WC)) WC = tolower(WC);\n"
" _stropped_source(PP++) = WC; _stropped_source(PP++) = 818 /* Unicode COMBINING LOW LINE */;\n"
" if (debug_stropping) fwprintf(stderr, L\"%lc%lc\", WC, (wchar_t)818);\n"
" }\n"
" FP++; // skip closing '\n"
" } else {\n"
" // Doesn't fit the pattern, so don't convert\n"
" // But first, check for character constants, eg '('\n"
" Peek = FP; WC = source(Peek);\n"
" if (WC != 0 && source(Peek+1) == '\\'') {\n"
" // Single character constant. We'll worry about strings later.\n"
" _stropped_source(PP++) = '\\'';\n"
" _stropped_source(PP++) = WC; FP += 1;\n"
" _stropped_source(PP++) = '\\''; FP += 1;\n"
" if (debug_stropping) fwprintf(stderr, L\"'%lc'\", WC);\n"
" } else {\n"
" _stropped_source(PP++) = '\\'';\n"
" if (debug_stropping) fwprintf(stderr, L\"'\");\n"
" }\n"
" }\n"
" continue;\n"
" }\n"
" _stropped_source(PP++) = WC;\n"
" if (debug_stropping) if (WC) fwprintf(stderr, L\"%lc\", WC);\n"
" if (WC == 0) break; // convert up to end of file.\n"
" }\n"
"\n"
" // copy back from stropped_source to source\n"
" for (FP = 0; FP < PP; FP++) {\n"
" _source(FP) = stropped_source(FP);\n"
" }\n"
" // free stropped_source\n"
" FREE_FLEX(stropped_source);\n"
"\n"
"#endif\n"
" return TRUE;\n",
};
parsefn parsetime[NUM_SEMANTIC_PHRASES] = {
/*0*/ &parse_init,
/*1*/ &parse_terminate,
/*2*/ &parse_convert_keywords,
};
// Comments are stored so that they can be re-inserted, should
// we need to regenerate a grammar.g file from this header file.
const wchar_t *xcomment[NUM_PHRASES] = {
/* 0*/ NULL,
/* 1*/ NULL,
/* 2*/ NULL,
/* 3*/ NULL,
/* 4*/ NULL,
/* 5*/ NULL,
/* 6*/ NULL,
/* 7*/ NULL,
/* 8*/ NULL,
/* 9*/ NULL,
/* 10*/ NULL,
/* 11*/ NULL,