2
(* Yacc parser template (TP Yacc V3.0), V1.2 6-17-91 AG *)
4
(* global definitions: *)
8
TP Yacc - Yet Another Compiler Compiler for Turbo Pascal
10
Copyright (C) 1990-92 Albert Graef <ag@muwiinfa.geschichte.uni-mainz.de>
11
Copyright (C) 1996 Berend de Boer <berend@pobox.com>
13
This program is free software; you can redistribute it and/or modify
14
it under the terms of the GNU General Public License as published by
15
the Free Software Foundation; either version 2 of the License, or
16
(at your option) any later version.
18
This program is distributed in the hope that it will be useful,
19
but WITHOUT ANY WARRANTY; without even the implied warranty of
20
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
GNU General Public License for more details.
23
You should have received a copy of the GNU General Public License
24
along with this program; if not, write to the Free Software
25
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29
$Modtime: 96-08-01 11:24 $
34
Version 3.0 as of April 91
35
Version 3.0a as of May 92 (bug fixes in precedence and type information
40
* ***************** Version 2 *****************
41
* User: Berend Date: 96-10-10 Time: 21:16
42
* Updated in $/Lex and Yacc/tply
43
* Updated for protected mode, windows and Delphi 1.X and 2.X.
47
------------------------- Synopsis ------------------------
49
Synopsis yacc [options] yacc-file[.y] [output-file[.pas]]
53
-v "Verbose:" Yacc generates a readable description of the generated
54
parser, written to yacc-file with new extension .lst.
56
-d "Debug:" Yacc generates parser with debugging output.
60
This is a reimplementation of the popular UNIX compiler generator
61
Yacc for MS-DOS and Turbo Pascal.
63
Differences from UNIX Yacc:
65
- Produces output code for Turbo Pascal, rather than for C.
67
- Does not support %union definitions. Instead, a value type is declared
68
by specifying the type identifier *itself* as the tag of a %token
69
or %type definition. Yacc will automatically generate an appropriate
70
yylval variable of a variant record type (YYSType) which is capable of
71
holding values of any of the types used in %token and %type.
73
Type checking is *very* strict. If you use type definitions, then
74
any symbol referred to in an action *must* have a type introduced
75
in a type definition. Either the symbol must have been assigned a
76
type in the definitions section, or the $<type-identifier> notation
77
must be used. The syntax of the %type definition has been changed
78
slightly to allow definitions of the form
79
%type <type-identifier>
80
(omitting the nonterminals) which may be used to declare types which
81
are not assigned to any grammar symbol, but are used with the
84
- The parse tables constructed by this Yacc version are slightly greater
85
than those constructed by UNIX Yacc, since a reduce action will only be
86
chosen as the default action if it is the *only* action in the state.
87
In difference, UNIX Yacc chooses a reduce action as the default action
88
whenever it is the only *reduce* action of the state (even if there are
91
This solves a bug in UNIX Yacc that makes the generated parser start
92
error recovery too late with certain types of error productions (see
93
also Schreiner/Friedman, "Introduction to compiler construction with
94
UNIX," 1985). Also, errors will be caught sooner in most cases where
95
standard Yacc would carry out an additional (default) reduction before
98
------------------------- Synopsis ------------------------
127
YaccLib, YaccBase, YaccMsgs, YaccSem, YaccTabl, YaccPars;
137
const PNONASSOC = 265;
146
var yylval : YYSType;
148
function yylex : Integer; forward;
150
function yyparse : Integer;
152
var yystate, yysp, yyn : Integer;
153
yys : array [1..yymaxdepth] of Integer;
154
yyv : array [1..yymaxdepth] of YYSType;
157
procedure yyaction ( yyruleno : Integer );
158
(* local definitions: *)
163
yyval := yyv[yysp-0];
166
yyval := yyv[yysp-0];
169
yyval := yyv[yysp-0];
172
yyval := yyv[yysp-0];
175
yyval := yyv[yysp-0];
196
yyval := yyv[yysp-0];
202
yyval := yyv[yysp-0];
205
yyval := yyv[yysp-0];
208
error(rcurl_expected);
211
yyval := yyv[yysp-0];
223
yyval := yyv[yysp-0];
226
yyval := yyv[yysp-0];
229
error(rbrace_expected);
232
yyval := yyv[yysp-0];
235
yyval := yyv[yysp-0];
238
error(rangle_expected);
241
yyval := yyv[yysp-0];
254
yyval := yyv[yysp-5];
270
startnt := ntsym(yyv[yysp-0]);
273
error(ident_expected);
279
yyval := yyv[yysp-2];
285
yyval := yyv[yysp-3];
288
act_prec := new_prec_level(left);
291
yyval := yyv[yysp-3];
294
act_prec := new_prec_level(right);
297
yyval := yyv[yysp-3];
300
act_prec := new_prec_level(nonassoc);
303
yyval := yyv[yysp-3];
306
yyval := yyv[yysp-2];
309
yyval := yyv[yysp-1];
315
act_type := yyv[yysp-1]; add_type(yyv[yysp-1]);
318
yyval := yyv[yysp-0];
327
error(ident_expected);
333
error(ident_expected);
337
sym_type^[yyv[yysp-0]] := act_type;
339
sym_prec^[yyv[yysp-0]] := act_prec;
342
litsym(yyv[yysp-0], 0);
344
sym_type^[litsym(yyv[yysp-0], 0)] := act_type;
346
sym_prec^[litsym(yyv[yysp-0], 0)] := act_prec;
349
litsym(yyv[yysp-0], 0);
351
sym_type^[litsym(yyv[yysp-0], 0)] := act_type;
353
sym_prec^[litsym(yyv[yysp-0], 0)] := act_prec;
356
litsym(yyv[yysp-1], 0);
358
sym_type^[litsym(yyv[yysp-1], yyv[yysp-0])] := act_type;
360
sym_prec^[litsym(yyv[yysp-1], 0)] := act_prec;
363
litsym(yyv[yysp-1], 0);
365
sym_type^[litsym(yyv[yysp-1], yyv[yysp-0])] := act_type;
367
sym_prec^[litsym(yyv[yysp-1], 0)] := act_prec;
370
yyval := yyv[yysp-0];
379
error(ident_expected);
385
error(ident_expected);
389
sym_type^[ntsym(yyv[yysp-0])] := act_type;
395
yyval := yyv[yysp-1];
404
yyval := yyv[yysp-4];
410
error(error_in_rule);
413
error(error_in_rule);
416
start_rule(ntsym(yyv[yysp-0]));
425
yyval := yyv[yysp-0];
436
add_symbol(yyv[yysp-0]); yyerrok;
439
add_symbol(sym(yyv[yysp-0])); yyerrok;
442
add_symbol(sym(yyv[yysp-0])); yyerrok;
448
error(error_in_rule);
454
yyval := yyv[yysp-2];
462
add_rule_prec(yyv[yysp-0]);
465
yyval := yyv[yysp-3];
468
add_rule_prec(litsym(yyv[yysp-0], 0));
471
yyval := yyv[yysp-3];
474
add_rule_prec(litsym(yyv[yysp-0], 0));
477
yyval := yyv[yysp-3];
480
yyval := yyv[yysp-1];
506
yya : array [1..yynacts] of YYARec = (
509
( sym: 256; act: 12 ),
510
( sym: 262; act: 13 ),
511
( sym: 263; act: 14 ),
512
( sym: 264; act: 15 ),
513
( sym: 265; act: 16 ),
514
( sym: 266; act: 17 ),
515
( sym: 267; act: 18 ),
516
( sym: 269; act: 19 ),
517
( sym: 270; act: 20 ),
524
( sym: 256; act: 24 ),
525
( sym: 257; act: 25 ),
527
( sym: 60; act: 28 ),
528
( sym: 256; act: -50 ),
529
( sym: 257; act: -50 ),
530
( sym: 262; act: -50 ),
531
( sym: 263; act: -50 ),
532
( sym: 264; act: -50 ),
533
( sym: 265; act: -50 ),
534
( sym: 266; act: -50 ),
535
( sym: 267; act: -50 ),
536
( sym: 269; act: -50 ),
537
( sym: 270; act: -50 ),
552
( sym: 256; act: 34 ),
553
( sym: 271; act: 35 ),
555
( sym: 256; act: 39 ),
556
( sym: 270; act: 20 ),
557
( sym: 258; act: -70 ),
562
( sym: 256; act: 43 ),
563
( sym: 257; act: 25 ),
564
( sym: 262; act: -49 ),
565
( sym: 263; act: -49 ),
566
( sym: 264; act: -49 ),
567
( sym: 265; act: -49 ),
568
( sym: 266; act: -49 ),
569
( sym: 267; act: -49 ),
570
( sym: 269; act: -49 ),
571
( sym: 270; act: -49 ),
573
( sym: 257; act: 25 ),
576
( sym: 60; act: 28 ),
577
( sym: 256; act: -50 ),
578
( sym: 257; act: -50 ),
579
( sym: 259; act: -50 ),
580
( sym: 260; act: -50 ),
582
( sym: 60; act: 28 ),
583
( sym: 256; act: -50 ),
584
( sym: 257; act: -50 ),
585
( sym: 259; act: -50 ),
586
( sym: 260; act: -50 ),
588
( sym: 60; act: 28 ),
589
( sym: 256; act: -50 ),
590
( sym: 257; act: -50 ),
591
( sym: 259; act: -50 ),
592
( sym: 260; act: -50 ),
594
( sym: 60; act: 28 ),
595
( sym: 256; act: -50 ),
596
( sym: 257; act: -50 ),
597
( sym: 259; act: -50 ),
598
( sym: 260; act: -50 ),
603
( sym: 258; act: 51 ),
605
( sym: 124; act: 56 ),
606
( sym: 256; act: 57 ),
607
( sym: 258; act: 51 ),
608
( sym: 0; act: -29 ),
609
( sym: 269; act: -29 ),
614
( sym: 44; act: 61 ),
615
( sym: 256; act: 62 ),
616
( sym: 257; act: 25 ),
617
( sym: 262; act: -48 ),
618
( sym: 263; act: -48 ),
619
( sym: 264; act: -48 ),
620
( sym: 265; act: -48 ),
621
( sym: 266; act: -48 ),
622
( sym: 267; act: -48 ),
623
( sym: 269; act: -48 ),
624
( sym: 270; act: -48 ),
628
( sym: 62; act: 64 ),
629
( sym: 256; act: 65 ),
631
( sym: 256; act: 71 ),
632
( sym: 257; act: 25 ),
633
( sym: 259; act: 72 ),
634
( sym: 260; act: 73 ),
636
( sym: 256; act: 71 ),
637
( sym: 257; act: 25 ),
638
( sym: 259; act: 72 ),
639
( sym: 260; act: 73 ),
641
( sym: 256; act: 71 ),
642
( sym: 257; act: 25 ),
643
( sym: 259; act: 72 ),
644
( sym: 260; act: 73 ),
646
( sym: 256; act: 71 ),
647
( sym: 257; act: 25 ),
648
( sym: 259; act: 72 ),
649
( sym: 260; act: 73 ),
656
( sym: 269; act: 19 ),
657
( sym: 0; act: -31 ),
662
( sym: 256; act: 34 ),
663
( sym: 271; act: 35 ),
666
( sym: 256; act: 83 ),
667
( sym: 257; act: 25 ),
675
( sym: 44; act: 61 ),
676
( sym: 256; act: 86 ),
677
( sym: 257; act: 25 ),
678
( sym: 259; act: 72 ),
679
( sym: 260; act: 73 ),
680
( sym: 262; act: -47 ),
681
( sym: 263; act: -47 ),
682
( sym: 264; act: -47 ),
683
( sym: 265; act: -47 ),
684
( sym: 266; act: -47 ),
685
( sym: 267; act: -47 ),
686
( sym: 269; act: -47 ),
687
( sym: 270; act: -47 ),
689
( sym: 261; act: 88 ),
690
( sym: 44; act: -59 ),
691
( sym: 256; act: -59 ),
692
( sym: 257; act: -59 ),
693
( sym: 259; act: -59 ),
694
( sym: 260; act: -59 ),
695
( sym: 262; act: -59 ),
696
( sym: 263; act: -59 ),
697
( sym: 264; act: -59 ),
698
( sym: 265; act: -59 ),
699
( sym: 266; act: -59 ),
700
( sym: 267; act: -59 ),
701
( sym: 269; act: -59 ),
702
( sym: 270; act: -59 ),
705
( sym: 261; act: 88 ),
706
( sym: 44; act: -60 ),
707
( sym: 256; act: -60 ),
708
( sym: 257; act: -60 ),
709
( sym: 259; act: -60 ),
710
( sym: 260; act: -60 ),
711
( sym: 262; act: -60 ),
712
( sym: 263; act: -60 ),
713
( sym: 264; act: -60 ),
714
( sym: 265; act: -60 ),
715
( sym: 266; act: -60 ),
716
( sym: 267; act: -60 ),
717
( sym: 269; act: -60 ),
718
( sym: 270; act: -60 ),
723
( sym: 44; act: 61 ),
724
( sym: 256; act: 86 ),
725
( sym: 257; act: 25 ),
726
( sym: 259; act: 72 ),
727
( sym: 260; act: 73 ),
728
( sym: 262; act: -45 ),
729
( sym: 263; act: -45 ),
730
( sym: 264; act: -45 ),
731
( sym: 265; act: -45 ),
732
( sym: 266; act: -45 ),
733
( sym: 267; act: -45 ),
734
( sym: 269; act: -45 ),
735
( sym: 270; act: -45 ),
737
( sym: 44; act: 61 ),
738
( sym: 256; act: 86 ),
739
( sym: 257; act: 25 ),
740
( sym: 259; act: 72 ),
741
( sym: 260; act: 73 ),
742
( sym: 262; act: -43 ),
743
( sym: 263; act: -43 ),
744
( sym: 264; act: -43 ),
745
( sym: 265; act: -43 ),
746
( sym: 266; act: -43 ),
747
( sym: 267; act: -43 ),
748
( sym: 269; act: -43 ),
749
( sym: 270; act: -43 ),
751
( sym: 44; act: 61 ),
752
( sym: 256; act: 86 ),
753
( sym: 257; act: 25 ),
754
( sym: 259; act: 72 ),
755
( sym: 260; act: 73 ),
756
( sym: 262; act: -41 ),
757
( sym: 263; act: -41 ),
758
( sym: 264; act: -41 ),
759
( sym: 265; act: -41 ),
760
( sym: 266; act: -41 ),
761
( sym: 267; act: -41 ),
762
( sym: 269; act: -41 ),
763
( sym: 270; act: -41 ),
765
( sym: 58; act: 91 ),
774
( sym: 256; act: 95 ),
775
( sym: 257; act: 25 ),
776
( sym: 259; act: 72 ),
777
( sym: 260; act: 73 ),
785
( sym: 61; act: 105 ),
786
( sym: 123; act: 106 ),
787
( sym: 256; act: 107 ),
788
( sym: 257; act: 25 ),
789
( sym: 259; act: 72 ),
790
( sym: 260; act: 73 ),
791
( sym: 268; act: 108 ),
792
( sym: 0; act: -93 ),
793
( sym: 59; act: -93 ),
794
( sym: 124; act: -93 ),
795
( sym: 258; act: -93 ),
796
( sym: 269; act: -93 ),
798
( sym: 258; act: 51 ),
804
( sym: 59; act: 112 ),
805
( sym: 0; act: -83 ),
806
( sym: 124; act: -83 ),
807
( sym: 256; act: -83 ),
808
( sym: 258; act: -83 ),
809
( sym: 269; act: -83 ),
813
( sym: 257; act: 25 ),
814
( sym: 259; act: 72 ),
815
( sym: 260; act: 73 ),
825
( sym: 61; act: 105 ),
826
( sym: 123; act: 106 ),
827
( sym: 256; act: 107 ),
828
( sym: 257; act: 25 ),
829
( sym: 259; act: 72 ),
830
( sym: 260; act: 73 ),
831
( sym: 268; act: 108 ),
832
( sym: 0; act: -93 ),
833
( sym: 59; act: -93 ),
834
( sym: 124; act: -93 ),
835
( sym: 258; act: -93 ),
836
( sym: 269; act: -93 ),
840
( sym: 125; act: 119 ),
841
( sym: 256; act: 120 ),
846
( sym: 59; act: 112 ),
847
( sym: 0; act: -80 ),
848
( sym: 124; act: -80 ),
849
( sym: 256; act: -80 ),
850
( sym: 258; act: -80 ),
851
( sym: 269; act: -80 ),
856
( sym: 61; act: 105 ),
857
( sym: 123; act: 106 ),
858
( sym: 0; act: -101 ),
859
( sym: 59; act: -101 ),
860
( sym: 124; act: -101 ),
861
( sym: 256; act: -101 ),
862
( sym: 258; act: -101 ),
863
( sym: 269; act: -101 ),
865
( sym: 61; act: 105 ),
866
( sym: 123; act: 106 ),
867
( sym: 0; act: -101 ),
868
( sym: 59; act: -101 ),
869
( sym: 124; act: -101 ),
870
( sym: 256; act: -101 ),
871
( sym: 258; act: -101 ),
872
( sym: 269; act: -101 ),
874
( sym: 61; act: 105 ),
875
( sym: 123; act: 106 ),
876
( sym: 0; act: -101 ),
877
( sym: 59; act: -101 ),
878
( sym: 124; act: -101 ),
879
( sym: 256; act: -101 ),
880
( sym: 258; act: -101 ),
881
( sym: 269; act: -101 )
888
yyg : array [1..yyngotos] of YYARec = (
890
( sym: -27; act: 1 ),
893
( sym: -32; act: 3 ),
894
( sym: -16; act: 4 ),
895
( sym: -15; act: 5 ),
896
( sym: -13; act: 6 ),
897
( sym: -12; act: 7 ),
898
( sym: -11; act: 8 ),
899
( sym: -10; act: 9 ),
900
( sym: -9; act: 10 ),
901
( sym: -8; act: 11 ),
905
( sym: -33; act: 21 ),
907
( sym: -29; act: 22 ),
909
( sym: -3; act: 23 ),
911
( sym: -34; act: 26 ),
912
( sym: -24; act: 27 ),
914
( sym: -39; act: 29 ),
916
( sym: -38; act: 30 ),
918
( sym: -37; act: 31 ),
920
( sym: -35; act: 32 ),
931
( sym: -17; act: 33 ),
933
( sym: -44; act: 36 ),
934
( sym: -28; act: 37 ),
935
( sym: -16; act: 38 ),
940
( sym: -42; act: 40 ),
941
( sym: -40; act: 41 ),
942
( sym: -3; act: 42 ),
944
( sym: -3; act: 44 ),
947
( sym: -34; act: 45 ),
948
( sym: -24; act: 27 ),
950
( sym: -34; act: 46 ),
951
( sym: -24; act: 27 ),
953
( sym: -34; act: 47 ),
954
( sym: -24; act: 27 ),
956
( sym: -34; act: 48 ),
957
( sym: -24; act: 27 ),
962
( sym: -43; act: 49 ),
963
( sym: -4; act: 50 ),
965
( sym: -47; act: 52 ),
966
( sym: -43; act: 53 ),
967
( sym: -31; act: 54 ),
968
( sym: -21; act: 55 ),
969
( sym: -4; act: 50 ),
971
( sym: -45; act: 58 ),
975
( sym: -42; act: 59 ),
976
( sym: -18; act: 60 ),
977
( sym: -3; act: 42 ),
981
( sym: -25; act: 63 ),
983
( sym: -41; act: 66 ),
984
( sym: -36; act: 67 ),
985
( sym: -6; act: 68 ),
986
( sym: -5; act: 69 ),
987
( sym: -3; act: 70 ),
989
( sym: -41; act: 66 ),
990
( sym: -36; act: 74 ),
991
( sym: -6; act: 68 ),
992
( sym: -5; act: 69 ),
993
( sym: -3; act: 70 ),
995
( sym: -41; act: 66 ),
996
( sym: -36; act: 75 ),
997
( sym: -6; act: 68 ),
998
( sym: -5; act: 69 ),
999
( sym: -3; act: 70 ),
1001
( sym: -41; act: 66 ),
1002
( sym: -36; act: 76 ),
1003
( sym: -6; act: 68 ),
1004
( sym: -5; act: 69 ),
1005
( sym: -3; act: 70 ),
1008
( sym: -48; act: 77 ),
1013
( sym: -30; act: 78 ),
1014
( sym: -15; act: 79 ),
1016
( sym: -52; act: 80 ),
1020
( sym: -17; act: 81 ),
1023
( sym: -42; act: 82 ),
1024
( sym: -3; act: 42 ),
1032
( sym: -41; act: 84 ),
1033
( sym: -18; act: 85 ),
1034
( sym: -6; act: 68 ),
1035
( sym: -5; act: 69 ),
1036
( sym: -3; act: 70 ),
1038
( sym: -7; act: 87 ),
1041
( sym: -7; act: 89 ),
1046
( sym: -41; act: 84 ),
1047
( sym: -18; act: 85 ),
1048
( sym: -6; act: 68 ),
1049
( sym: -5; act: 69 ),
1050
( sym: -3; act: 70 ),
1052
( sym: -41; act: 84 ),
1053
( sym: -18; act: 85 ),
1054
( sym: -6; act: 68 ),
1055
( sym: -5; act: 69 ),
1056
( sym: -3; act: 70 ),
1058
( sym: -41; act: 84 ),
1059
( sym: -18; act: 85 ),
1060
( sym: -6; act: 68 ),
1061
( sym: -5; act: 69 ),
1062
( sym: -3; act: 70 ),
1064
( sym: -19; act: 90 ),
1068
( sym: -49; act: 92 ),
1070
( sym: -46; act: 93 ),
1075
( sym: -41; act: 94 ),
1076
( sym: -6; act: 68 ),
1077
( sym: -5; act: 69 ),
1078
( sym: -3; act: 70 ),
1084
( sym: -50; act: 96 ),
1087
( sym: -53; act: 97 ),
1088
( sym: -51; act: 98 ),
1089
( sym: -26; act: 99 ),
1090
( sym: -22; act: 100 ),
1091
( sym: -14; act: 101 ),
1092
( sym: -6; act: 102 ),
1093
( sym: -5; act: 103 ),
1094
( sym: -3; act: 104 ),
1096
( sym: -43; act: 109 ),
1097
( sym: -4; act: 50 ),
1101
( sym: -49; act: 110 ),
1104
( sym: -20; act: 111 ),
1107
( sym: -54; act: 113 ),
1109
( sym: -6; act: 114 ),
1110
( sym: -5; act: 115 ),
1111
( sym: -3; act: 116 ),
1121
( sym: -53; act: 97 ),
1122
( sym: -51; act: 117 ),
1123
( sym: -26; act: 99 ),
1124
( sym: -22; act: 100 ),
1125
( sym: -14; act: 101 ),
1126
( sym: -6; act: 102 ),
1127
( sym: -5; act: 103 ),
1128
( sym: -3; act: 104 ),
1132
( sym: -23; act: 118 ),
1134
( sym: -57; act: 121 ),
1136
( sym: -56; act: 122 ),
1138
( sym: -58; act: 123 ),
1140
( sym: -20; act: 111 ),
1145
( sym: -55; act: 124 ),
1146
( sym: -53; act: 125 ),
1147
( sym: -26; act: 99 ),
1148
( sym: -22; act: 100 ),
1150
( sym: -55; act: 126 ),
1151
( sym: -53; act: 125 ),
1152
( sym: -26; act: 99 ),
1153
( sym: -22; act: 100 ),
1155
( sym: -55; act: 127 ),
1156
( sym: -53; act: 125 ),
1157
( sym: -26; act: 99 ),
1158
( sym: -22; act: 100 )
1165
yyd : array [0..yynstates-1] of Integer = (
1296
yyal : array [0..yynstates-1] of Integer = (
1427
yyah : array [0..yynstates-1] of Integer = (
1558
yygl : array [0..yynstates-1] of Integer = (
1689
yygh : array [0..yynstates-1] of Integer = (
1820
yyr : array [1..yynrules] of YYRRec = (
1821
{ 1: } ( len: 1; sym: -3 ),
1822
{ 2: } ( len: 1; sym: -4 ),
1823
{ 3: } ( len: 1; sym: -5 ),
1824
{ 4: } ( len: 1; sym: -6 ),
1825
{ 5: } ( len: 1; sym: -7 ),
1826
{ 6: } ( len: 1; sym: -8 ),
1827
{ 7: } ( len: 1; sym: -9 ),
1828
{ 8: } ( len: 1; sym: -10 ),
1829
{ 9: } ( len: 1; sym: -11 ),
1830
{ 10: } ( len: 1; sym: -12 ),
1831
{ 11: } ( len: 1; sym: -13 ),
1832
{ 12: } ( len: 1; sym: -14 ),
1833
{ 13: } ( len: 1; sym: -15 ),
1834
{ 14: } ( len: 1; sym: -16 ),
1835
{ 15: } ( len: 1; sym: -17 ),
1836
{ 16: } ( len: 1; sym: -17 ),
1837
{ 17: } ( len: 1; sym: -18 ),
1838
{ 18: } ( len: 1; sym: -19 ),
1839
{ 19: } ( len: 1; sym: -20 ),
1840
{ 20: } ( len: 1; sym: -21 ),
1841
{ 21: } ( len: 1; sym: -22 ),
1842
{ 22: } ( len: 1; sym: -23 ),
1843
{ 23: } ( len: 1; sym: -23 ),
1844
{ 24: } ( len: 1; sym: -24 ),
1845
{ 25: } ( len: 1; sym: -25 ),
1846
{ 26: } ( len: 1; sym: -25 ),
1847
{ 27: } ( len: 1; sym: -26 ),
1848
{ 28: } ( len: 0; sym: -29 ),
1849
{ 29: } ( len: 0; sym: -31 ),
1850
{ 30: } ( len: 6; sym: -2 ),
1851
{ 31: } ( len: 0; sym: -30 ),
1852
{ 32: } ( len: 1; sym: -30 ),
1853
{ 33: } ( len: 0; sym: -27 ),
1854
{ 34: } ( len: 2; sym: -27 ),
1855
{ 35: } ( len: 2; sym: -27 ),
1856
{ 36: } ( len: 2; sym: -32 ),
1857
{ 37: } ( len: 2; sym: -32 ),
1858
{ 38: } ( len: 0; sym: -33 ),
1859
{ 39: } ( len: 3; sym: -32 ),
1860
{ 40: } ( len: 0; sym: -35 ),
1861
{ 41: } ( len: 4; sym: -32 ),
1862
{ 42: } ( len: 0; sym: -37 ),
1863
{ 43: } ( len: 4; sym: -32 ),
1864
{ 44: } ( len: 0; sym: -38 ),
1865
{ 45: } ( len: 4; sym: -32 ),
1866
{ 46: } ( len: 0; sym: -39 ),
1867
{ 47: } ( len: 4; sym: -32 ),
1868
{ 48: } ( len: 3; sym: -32 ),
1869
{ 49: } ( len: 2; sym: -32 ),
1870
{ 50: } ( len: 0; sym: -34 ),
1871
{ 51: } ( len: 3; sym: -34 ),
1872
{ 52: } ( len: 1; sym: -36 ),
1873
{ 53: } ( len: 2; sym: -36 ),
1874
{ 54: } ( len: 3; sym: -36 ),
1875
{ 55: } ( len: 1; sym: -36 ),
1876
{ 56: } ( len: 2; sym: -36 ),
1877
{ 57: } ( len: 3; sym: -36 ),
1878
{ 58: } ( len: 1; sym: -41 ),
1879
{ 59: } ( len: 1; sym: -41 ),
1880
{ 60: } ( len: 1; sym: -41 ),
1881
{ 61: } ( len: 2; sym: -41 ),
1882
{ 62: } ( len: 2; sym: -41 ),
1883
{ 63: } ( len: 1; sym: -40 ),
1884
{ 64: } ( len: 2; sym: -40 ),
1885
{ 65: } ( len: 3; sym: -40 ),
1886
{ 66: } ( len: 1; sym: -40 ),
1887
{ 67: } ( len: 2; sym: -40 ),
1888
{ 68: } ( len: 3; sym: -40 ),
1889
{ 69: } ( len: 1; sym: -42 ),
1890
{ 70: } ( len: 0; sym: -44 ),
1891
{ 71: } ( len: 2; sym: -28 ),
1892
{ 72: } ( len: 0; sym: -45 ),
1893
{ 73: } ( len: 0; sym: -46 ),
1894
{ 74: } ( len: 5; sym: -28 ),
1895
{ 75: } ( len: 2; sym: -28 ),
1896
{ 76: } ( len: 1; sym: -28 ),
1897
{ 77: } ( len: 2; sym: -28 ),
1898
{ 78: } ( len: 0; sym: -48 ),
1899
{ 79: } ( len: 0; sym: -50 ),
1900
{ 80: } ( len: 6; sym: -43 ),
1901
{ 81: } ( len: 1; sym: -47 ),
1902
{ 82: } ( len: 0; sym: -52 ),
1903
{ 83: } ( len: 4; sym: -47 ),
1904
{ 84: } ( len: 0; sym: -49 ),
1905
{ 85: } ( len: 2; sym: -49 ),
1906
{ 86: } ( len: 2; sym: -49 ),
1907
{ 87: } ( len: 2; sym: -49 ),
1908
{ 88: } ( len: 2; sym: -49 ),
1909
{ 89: } ( len: 2; sym: -49 ),
1910
{ 90: } ( len: 0; sym: -54 ),
1911
{ 91: } ( len: 3; sym: -53 ),
1912
{ 92: } ( len: 1; sym: -53 ),
1913
{ 93: } ( len: 0; sym: -51 ),
1914
{ 94: } ( len: 0; sym: -56 ),
1915
{ 95: } ( len: 4; sym: -51 ),
1916
{ 96: } ( len: 0; sym: -57 ),
1917
{ 97: } ( len: 4; sym: -51 ),
1918
{ 98: } ( len: 0; sym: -58 ),
1919
{ 99: } ( len: 4; sym: -51 ),
1920
{ 100: } ( len: 2; sym: -51 ),
1921
{ 101: } ( len: 0; sym: -55 ),
1922
{ 102: } ( len: 1; sym: -55 )
1926
const _error = 256; (* error token *)
1928
function yyact(state, sym : Integer; var act : Integer) : Boolean;
1929
(* search action table *)
1933
while (k<=yyah[state]) and (yya[k].sym<>sym) do inc(k);
1934
if k>yyah[state] then
1943
function yygoto(state, sym : Integer; var nstate : Integer) : Boolean;
1944
(* search goto table *)
1948
while (k<=yygh[state]) and (yyg[k].sym<>sym) do inc(k);
1949
if k>yygh[state] then
1953
nstate := yyg[k].act;
1958
label parse, next, error, errlab, shift, reduce, accept, abort;
1964
yystate := 0; yychar := -1; yynerrs := 0; yyerrflag := 0; yysp := 0;
1974
(* push state and value: *)
1977
if yysp>yymaxdepth then
1979
yyerror('yyparse stack overflow');
1982
yys[yysp] := yystate; yyv[yysp] := yyval;
1986
if (yyd[yystate]=0) and (yychar=-1) then
1987
(* get next symbol *)
1989
yychar := yylex; if yychar<0 then yychar := 0;
1992
if yydebug then writeln('state ', yystate, ', char ', yychar);
1994
(* determine parse action: *)
1996
yyn := yyd[yystate];
1997
if yyn<>0 then goto reduce; (* simple state *)
1999
(* no default action; search parse table *)
2001
if not yyact(yystate, yychar, yyn) then goto error
2002
else if yyn>0 then goto shift
2003
else if yyn<0 then goto reduce
2008
(* error; start error recovery: *)
2010
if yyerrflag=0 then yyerror('syntax error');
2014
if yyerrflag=0 then inc(yynerrs); (* new error *)
2016
if yyerrflag<=2 then (* incomplete recovery; try again *)
2019
(* uncover a state with shift action on error token *)
2020
while (yysp>0) and not ( yyact(yys[yysp], _error, yyn) and
2025
writeln('error recovery pops state ', yys[yysp], ', uncovers ',
2028
writeln('error recovery fails ... abort');
2031
if yysp=0 then goto abort; (* parser has fallen from stack; abort *)
2032
yystate := yyn; (* simulate shift on error *)
2035
else (* no shift yet; discard symbol *)
2037
if yydebug then writeln('error recovery discards char ', yychar);
2038
if yychar=0 then goto abort; (* end of input; abort *)
2039
yychar := -1; goto next; (* clear lookahead char and try again *)
2044
(* go to new state, clear lookahead character: *)
2046
yystate := yyn; yychar := -1; yyval := yylval;
2047
if yyerrflag>0 then dec(yyerrflag);
2053
(* execute action, pop rule from stack, and go to next state: *)
2055
if yydebug then writeln('reduce ', -yyn);
2057
yyflag := yyfnone; yyaction(-yyn);
2058
dec(yysp, yyr[-yyn].len);
2059
if yygoto(yys[yysp], yyr[-yyn].sym, yyn) then yystate := yyn;
2061
(* handle action calls to yyaccept, yyabort and yyerror: *)
2064
yyfaccept : goto accept;
2065
yyfabort : goto abort;
2066
yyferror : goto errlab;
2082
(* Lexical analyzer (implemented in Turbo Pascal for maximum efficiency): *)
2084
function yylex : integer;
2085
function end_of_input : boolean;
2087
end_of_input := (cno>length(line)) and eof(yyin)
2088
end(*end_of_input*);
2090
(* scan for nonempty character, skip comments *)
2091
procedure scan_comment;
2094
p := pos('*/', copy(line, cno, length(line)));
2099
while (p=0) and not eof(yyin) do
2103
p := pos('*/', line)
2107
cno := succ(length(line));
2108
error(open_comment_at_eof);
2111
cno := succ(succ(p))
2113
end(*scan_comment*);
2115
while not end_of_input do
2116
if cno<=length(line) then
2118
' ', tab : inc(cno);
2120
if (cno<length(line)) and (line[succ(cno)]='*') then
2136
function scan_ident : integer;
2137
(* scan an identifier *)
2143
while (cno<=length(line)) and (
2144
('A'<=upCase(line[cno])) and (upCase(line[cno])<='Z') or
2145
('0'<=line[cno]) and (line[cno]<='9') or
2147
(line[cno]='.') ) do
2149
idstr := idstr+line[cno];
2152
yylval := get_key(idstr);
2154
if not end_of_input and (line[cno]=':') then
2159
function scan_literal: integer;
2160
(* scan a literal, i.e. string *)
2167
while (cno<=length(line)) and (line[cno]<>idstr[1]) do
2168
if line[cno]='\' then
2169
if cno<length(line) then
2200
oct_val := ord(line[cno])-ord('0');
2202
while (cno<=length(line)) and
2203
('0'<=line[cno]) and
2206
oct_val := oct_val*8+ord(line[cno])-ord('0');
2209
idstr := idstr+chr(oct_val)
2213
idstr := idstr+line[cno];
2222
idstr := idstr+line[cno];
2225
if cno>length(line) then
2226
error(missing_string_terminator)
2229
if length(idstr)=2 then
2231
yylval := ord(idstr[2]);
2232
scan_literal := LITERAL;
2234
else if length(idstr)>1 then
2236
yylval := get_key(''''+copy(idstr, 2, pred(length(idstr)))+'''');
2237
scan_literal := LITID;
2240
scan_literal := ILLEGAL;
2241
end(*scan_literal*);
2242
function scan_num : integer;
2243
(* scan an unsigned integer *)
2248
numstr := line[cno];
2250
while (cno<=length(line)) and
2251
('0'<=line[cno]) and (line[cno]<='9') do
2253
numstr := numstr+line[cno];
2256
val(numstr, yylval, code);
2260
scan_num := ILLEGAL;
2262
function scan_keyword : integer;
2264
function lookup(key : String; var tok : integer) : boolean;
2265
(* table of Yacc keywords (unstropped): *)
2268
max_entry_length = 8;
2269
keys : array [1..no_of_entries] of String[max_entry_length] = (
2270
'0', '2', 'binary', 'left', 'nonassoc', 'prec', 'right',
2271
'start', 'term', 'token', 'type');
2272
toks : array [1..no_of_entries] of integer = (
2273
PTOKEN, PNONASSOC, PNONASSOC, PLEFT, PNONASSOC, PPREC, PRIGHT,
2274
PSTART, PTOKEN, PTOKEN, PTYPE);
2275
var m, n, k : integer;
2277
(* binary search: *)
2278
m := 1; n := no_of_entries;
2288
else if key>keys[k] then
2300
if cno<=length(line) then
2304
scan_keyword := PLEFT;
2309
scan_keyword := PRIGHT;
2314
scan_keyword := PPREC;
2324
scan_keyword := LCURL;
2329
scan_keyword := RCURL;
2332
'A'..'Z', 'a'..'z', '0'..'9' :
2334
keywstr := line[cno];
2336
while (cno<=length(line)) and (
2337
('A'<=upCase(line[cno])) and (upCase(line[cno])<='Z') or
2338
('0'<=line[cno]) and (line[cno]<='Z') ) do
2340
keywstr := keywstr+line[cno];
2343
if lookup(keywstr, tok) then
2346
scan_keyword := ILLEGAL
2348
else scan_keyword := ILLEGAL
2351
scan_keyword := ILLEGAL;
2352
end(*scan_keyword*);
2353
function scan_char : integer;
2354
(* scan any single character *)
2356
scan_char := ord(line[cno]);
2359
var lno0, cno0 : integer;
2363
lno0 := lno; cno0 := cno;
2364
if end_of_input then
2368
'A'..'Z', 'a'..'z', '_' : yylex := scan_ident;
2369
'''', '"' : yylex := scan_literal;
2370
'0'..'9' : yylex := scan_num;
2371
'%', '\' : yylex := scan_keyword;
2373
if (cno<length(line)) and (line[succ(cno)]='{') then
2380
else yylex := scan_char;
2393
codfilepath:='/usr/local/lib/fpc/lexyacc/';
2395
codfilepath:='/usr/lib/fpc/lexyacc/';
2398
codfilepath:=path(paramstr(0));
2405
(* parse command line: *)
2407
if paramCount=0 then
2417
for i := 1 to paramCount do
2418
if copy(paramStr(i), 1, 1)='-' then
2419
if upper(paramStr(i))='-V' then
2421
else if upper(paramStr(i))='-D' then
2425
writeln(invalid_option, paramStr(i));
2428
else if yfilename='' then
2429
yfilename := addExt(paramStr(i), 'y')
2430
else if pasfilename='' then
2431
pasfilename := addExt(paramStr(i), 'pas')
2434
writeln(illegal_no_args);
2438
if yfilename='' then
2440
writeln(illegal_no_args);
2444
if pasfilename='' then pasfilename := root(yfilename)+'.pas';
2445
lstfilename := root(yfilename)+'.lst';
2449
assign(yyin, yfilename);
2450
assign(yyout, pasfilename);
2451
assign(yylst, lstfilename);
2453
reset(yyin); if ioresult<>0 then fatal(cannot_open_file+yfilename);
2454
rewrite(yyout); if ioresult<>0 then fatal(cannot_open_file+pasfilename);
2455
rewrite(yylst); if ioresult<>0 then fatal(cannot_open_file+lstfilename);
2457
(* search code template in current directory, then on path where Yacc
2458
was executed from: *)
2459
codfilename := 'yyparse.cod';
2460
assign(yycod, codfilename);
2464
codfilename := codfilepath+'yyparse.cod';
2465
assign(yycod, codfilename);
2467
if ioresult<>0 then fatal(cannot_open_file+codfilename);
2470
(* parse source grammar: *)
2472
write('parse ... ');
2474
lno := 0; cno := 1; line := '';
2477
if debug then writeln(yyout, '{$define yydebug}');
2481
else if yychar=0 then
2482
error(unexpected_eof)
2484
error(syntax_error);
2486
if errors=0 then writeln('DONE');
2490
close(yyin); close(yyout); close(yylst); close(yycod);
2492
(* print statistics: *)
2495
writeln( lno, ' lines, ',
2496
errors, ' errors found.' )
2499
writeln( lno, ' lines, ',
2500
n_rules-1, '/', max_rules-1, ' rules, ',
2501
n_states, '/', max_states, ' s, ',
2502
n_items, '/', max_items, ' i, ',
2503
n_trans, '/', max_trans, ' t, ',
2504
n_redns, '/', max_redns, ' r.');
2505
if shift_reduce>0 then
2506
writeln(shift_reduce, ' shift/reduce conflicts.');
2507
if reduce_reduce>0 then
2508
writeln(reduce_reduce, ' reduce/reduce conflicts.');
2509
if never_reduced>0 then
2510
writeln(never_reduced, ' rules never reduced.');
2513
if warnings>0 then writeln(warnings, ' warnings.');
2517
writeln( n_bytes, '/', max_bytes, ' bytes of memory used.');
2526
if ioresult<>0 then ;
2529
if file_size(lstfilename)=0 then
2532
writeln('(see ', lstfilename, ' for more information)');