Mercurial > hg > index.cgi
annotate lwcc/parse_c.c @ 557:b2ee86298516
Reduce default optimization level to -O2
It seems -O3 isn't as reliable as it maybe should be. There is plenty of
information out there indicating that it is more likely to trigger compiler
bugs so setting the default to -O2 instead.
author | William Astle <lost@l-w.ca> |
---|---|
date | Fri, 08 Sep 2023 00:35:11 -0600 |
parents | a3e277c58df9 |
children |
rev | line source |
---|---|
314
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1 /* Driver template for the LEMON parser generator. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
2 ** The author disclaims copyright to this source code. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
3 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
4 /* First off, code is included that follows the "include" declaration |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
5 ** in the input grammar file. */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
6 #include <stdio.h> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
7 #line 1 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
8 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
9 #include <assert.h> // only needed due to a bug in lemon |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
10 #include <stdio.h> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
11 #include "parse.h" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
12 #include "tree.h" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
13 #line 14 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
14 /* Next is all token values, in a form suitable for use by makeheaders. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
15 ** This section will be null unless lemon is run with the -m switch. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
16 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
17 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
18 ** These constants (all generated automatically by the parser generator) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
19 ** specify the various kinds of tokens (terminals) that the parser |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
20 ** understands. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
21 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
22 ** Each symbol here is a terminal symbol in the grammar. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
23 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
24 /* Make sure the INTERFACE macro is defined. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
25 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
26 #ifndef INTERFACE |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
27 # define INTERFACE 1 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
28 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
29 /* The next thing included is series of defines which control |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
30 ** various aspects of the generated parser. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
31 ** YYCODETYPE is the data type used for storing terminal |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
32 ** and nonterminal numbers. "unsigned char" is |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
33 ** used if there are fewer than 250 terminals |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
34 ** and nonterminals. "int" is used otherwise. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
35 ** YYNOCODE is a number of type YYCODETYPE which corresponds |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
36 ** to no legal terminal or nonterminal number. This |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
37 ** number is used to fill in empty slots of the hash |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
38 ** table. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
39 ** YYFALLBACK If defined, this indicates that one or more tokens |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
40 ** have fall-back values which should be used if the |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
41 ** original value of the token will not parse. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
42 ** YYACTIONTYPE is the data type used for storing terminal |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
43 ** and nonterminal numbers. "unsigned char" is |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
44 ** used if there are fewer than 250 rules and |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
45 ** states combined. "int" is used otherwise. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
46 ** ParseTOKENTYPE is the data type used for minor tokens given |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
47 ** directly to the parser from the tokenizer. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
48 ** YYMINORTYPE is the data type used for all minor tokens. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
49 ** This is typically a union of many types, one of |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
50 ** which is ParseTOKENTYPE. The entry in the union |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
51 ** for base tokens is called "yy0". |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
52 ** YYSTACKDEPTH is the maximum depth of the parser's stack. If |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
53 ** zero the stack is dynamically sized using realloc() |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
54 ** ParseARG_SDECL A static variable declaration for the %extra_argument |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
55 ** ParseARG_PDECL A parameter declaration for the %extra_argument |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
56 ** ParseARG_STORE Code to store %extra_argument into yypParser |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
57 ** ParseARG_FETCH Code to extract %extra_argument from yypParser |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
58 ** YYNSTATE the combined number of states. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
59 ** YYNRULE the number of rules in the grammar |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
60 ** YYERRORSYMBOL is the code number of the error symbol. If not |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
61 ** defined, then do no error processing. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
62 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
63 #define YYCODETYPE unsigned char |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
64 #define YYNOCODE 30 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
65 #define YYACTIONTYPE unsigned char |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
66 #define ParseTOKENTYPE struct tokendata * |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
67 typedef union { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
68 int yyinit; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
69 ParseTOKENTYPE yy0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
70 node_t * yy18; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
71 } YYMINORTYPE; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
72 #ifndef YYSTACKDEPTH |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
73 #define YYSTACKDEPTH 100 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
74 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
75 #define ParseARG_SDECL struct parserinfo *pinfo ; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
76 #define ParseARG_PDECL , struct parserinfo *pinfo |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
77 #define ParseARG_FETCH struct parserinfo *pinfo = yypParser->pinfo |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
78 #define ParseARG_STORE yypParser->pinfo = pinfo |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
79 #define YYNSTATE 36 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
80 #define YYNRULE 30 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
81 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
82 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
83 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
84 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
85 /* The yyzerominor constant is used to initialize instances of |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
86 ** YYMINORTYPE objects to zero. */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
87 static const YYMINORTYPE yyzerominor = { 0 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
88 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
89 /* Define the yytestcase() macro to be a no-op if is not already defined |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
90 ** otherwise. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
91 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
92 ** Applications can choose to define yytestcase() in the %include section |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
93 ** to a macro that can assist in verifying code coverage. For production |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
94 ** code the yytestcase() macro should be turned off. But it is useful |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
95 ** for testing. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
96 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
97 #ifndef yytestcase |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
98 # define yytestcase(X) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
99 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
100 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
101 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
102 /* Next are the tables used to determine what action to take based on the |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
103 ** current state and lookahead token. These tables are used to implement |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
104 ** functions that take a state number and lookahead value and return an |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
105 ** action integer. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
106 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
107 ** Suppose the action integer is N. Then the action is determined as |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
108 ** follows |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
109 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
110 ** 0 <= N < YYNSTATE Shift N. That is, push the lookahead |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
111 ** token onto the stack and goto state N. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
112 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
113 ** YYNSTATE <= N < YYNSTATE+YYNRULE Reduce by rule N-YYNSTATE. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
114 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
115 ** N == YYNSTATE+YYNRULE A syntax error has occurred. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
116 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
117 ** N == YYNSTATE+YYNRULE+1 The parser accepts its input. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
118 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
119 ** N == YYNSTATE+YYNRULE+2 No such action. Denotes unused |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
120 ** slots in the yy_action[] table. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
121 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
122 ** The action table is constructed as a single large table named yy_action[]. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
123 ** Given state S and lookahead X, the action is computed as |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
124 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
125 ** yy_action[ yy_shift_ofst[S] + X ] |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
126 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
127 ** If the index value yy_shift_ofst[S]+X is out of range or if the value |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
128 ** yy_lookahead[yy_shift_ofst[S]+X] is not equal to X or if yy_shift_ofst[S] |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
129 ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
130 ** and that yy_default[S] should be used instead. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
131 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
132 ** The formula above is for computing the action when the lookahead is |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
133 ** a terminal symbol. If the lookahead is a non-terminal (as occurs after |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
134 ** a reduce action) then the yy_reduce_ofst[] array is used in place of |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
135 ** the yy_shift_ofst[] array and YY_REDUCE_USE_DFLT is used in place of |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
136 ** YY_SHIFT_USE_DFLT. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
137 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
138 ** The following are the tables generated in this section: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
139 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
140 ** yy_action[] A single table containing all actions. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
141 ** yy_lookahead[] A table containing the lookahead for each entry in |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
142 ** yy_action. Used to detect hash collisions. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
143 ** yy_shift_ofst[] For each state, the offset into yy_action for |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
144 ** shifting terminals. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
145 ** yy_reduce_ofst[] For each state, the offset into yy_action for |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
146 ** shifting non-terminals after a reduce. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
147 ** yy_default[] Default action for each state. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
148 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
149 #define YY_ACTTAB_COUNT (44) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
150 static const YYACTIONTYPE yy_action[] = { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
151 /* 0 */ 36, 27, 26, 29, 24, 23, 22, 7, 3, 2, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
152 /* 10 */ 16, 9, 14, 35, 34, 33, 6, 8, 25, 18, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
153 /* 20 */ 16, 9, 14, 21, 10, 10, 32, 20, 20, 30, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
154 /* 30 */ 67, 1, 19, 28, 15, 5, 4, 68, 11, 68, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
155 /* 40 */ 17, 31, 13, 12, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
156 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
157 static const YYCODETYPE yy_lookahead[] = { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
158 /* 0 */ 0, 2, 3, 16, 4, 5, 6, 7, 8, 9, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
159 /* 10 */ 10, 11, 12, 20, 21, 22, 23, 7, 25, 26, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
160 /* 20 */ 10, 11, 12, 6, 7, 7, 1, 10, 10, 1, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
161 /* 30 */ 18, 19, 10, 14, 10, 24, 27, 29, 13, 29, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
162 /* 40 */ 26, 28, 26, 15, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
163 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
164 #define YY_SHIFT_USE_DFLT (-14) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
165 #define YY_SHIFT_COUNT (12) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
166 #define YY_SHIFT_MIN (-13) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
167 #define YY_SHIFT_MAX (28) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
168 static const signed char yy_shift_ofst[] = { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
169 /* 0 */ -14, 0, 10, 10, 28, 25, -1, 17, 18, 24, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
170 /* 10 */ 22, 19, -13, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
171 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
172 #define YY_REDUCE_USE_DFLT (-8) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
173 #define YY_REDUCE_COUNT (6) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
174 #define YY_REDUCE_MIN (-7) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
175 #define YY_REDUCE_MAX (16) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
176 static const signed char yy_reduce_ofst[] = { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
177 /* 0 */ 12, -7, 16, 14, 13, 9, 11, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
178 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
179 static const YYACTIONTYPE yy_default[] = { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
180 /* 0 */ 38, 66, 51, 50, 66, 66, 66, 55, 55, 58, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
181 /* 10 */ 57, 66, 66, 52, 61, 60, 54, 53, 49, 59, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
182 /* 20 */ 56, 48, 47, 46, 45, 43, 44, 42, 64, 65, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
183 /* 30 */ 63, 62, 41, 40, 39, 37, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
184 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
185 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
186 /* The next table maps tokens into fallback tokens. If a construct |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
187 ** like the following: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
188 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
189 ** %fallback ID X Y Z. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
190 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
191 ** appears in the grammar, then ID becomes a fallback token for X, Y, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
192 ** and Z. Whenever one of the tokens X, Y, or Z is input to the parser |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
193 ** but it does not parse, the type of the token is changed to ID and |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
194 ** the parse is retried before an error is thrown. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
195 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
196 #ifdef YYFALLBACK |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
197 static const YYCODETYPE yyFallback[] = { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
198 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
199 #endif /* YYFALLBACK */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
200 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
201 /* The following structure represents a single element of the |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
202 ** parser's stack. Information stored includes: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
203 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
204 ** + The state number for the parser at this level of the stack. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
205 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
206 ** + The value of the token stored at this level of the stack. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
207 ** (In other words, the "major" token.) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
208 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
209 ** + The semantic value stored at this level of the stack. This is |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
210 ** the information used by the action routines in the grammar. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
211 ** It is sometimes called the "minor" token. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
212 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
213 struct yyStackEntry { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
214 YYACTIONTYPE stateno; /* The state-number */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
215 YYCODETYPE major; /* The major token value. This is the code |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
216 ** number for the token at this stack level */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
217 YYMINORTYPE minor; /* The user-supplied minor token value. This |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
218 ** is the value of the token */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
219 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
220 typedef struct yyStackEntry yyStackEntry; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
221 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
222 /* The state of the parser is completely contained in an instance of |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
223 ** the following structure */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
224 struct yyParser { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
225 int yyidx; /* Index of top element in stack */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
226 #ifdef YYTRACKMAXSTACKDEPTH |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
227 int yyidxMax; /* Maximum value of yyidx */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
228 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
229 int yyerrcnt; /* Shifts left before out of the error */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
230 ParseARG_SDECL /* A place to hold %extra_argument */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
231 #if YYSTACKDEPTH<=0 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
232 int yystksz; /* Current side of the stack */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
233 yyStackEntry *yystack; /* The parser's stack */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
234 #else |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
235 yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
236 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
237 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
238 typedef struct yyParser yyParser; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
239 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
240 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
241 #include <stdio.h> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
242 static FILE *yyTraceFILE = 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
243 static char *yyTracePrompt = 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
244 #endif /* NDEBUG */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
245 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
246 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
247 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
248 ** Turn parser tracing on by giving a stream to which to write the trace |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
249 ** and a prompt to preface each trace message. Tracing is turned off |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
250 ** by making either argument NULL |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
251 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
252 ** Inputs: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
253 ** <ul> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
254 ** <li> A FILE* to which trace output should be written. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
255 ** If NULL, then tracing is turned off. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
256 ** <li> A prefix string written at the beginning of every |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
257 ** line of trace output. If NULL, then tracing is |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
258 ** turned off. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
259 ** </ul> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
260 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
261 ** Outputs: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
262 ** None. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
263 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
264 void ParseTrace(FILE *TraceFILE, char *zTracePrompt){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
265 yyTraceFILE = TraceFILE; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
266 yyTracePrompt = zTracePrompt; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
267 if( yyTraceFILE==0 ) yyTracePrompt = 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
268 else if( yyTracePrompt==0 ) yyTraceFILE = 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
269 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
270 #endif /* NDEBUG */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
271 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
272 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
273 /* For tracing shifts, the names of all terminals and nonterminals |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
274 ** are required. The following table supplies these names */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
275 static const char *const yyTokenName[] = { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
276 "$", "ENDS", "IDENTIFIER", "STAR", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
277 "KW_VOID", "KW_FLOAT", "KW_DOUBLE", "KW_LONG", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
278 "KW_UNSIGNED", "KW_SIGNED", "KW_INT", "KW_SHORT", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
279 "KW_CHAR", "OPAREN", "CPAREN", "OBRACE", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
280 "CBRACE", "error", "program", "rprogram", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
281 "globaldecl", "vardecl", "fundecl", "datatype", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
282 "ident", "typename", "baseint", "arglist", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
283 "statementblock", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
284 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
285 #endif /* NDEBUG */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
286 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
287 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
288 /* For tracing reduce actions, the names of all rules are required. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
289 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
290 static const char *const yyRuleName[] = { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
291 /* 0 */ "program ::= rprogram", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
292 /* 1 */ "rprogram ::= rprogram globaldecl", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
293 /* 2 */ "rprogram ::=", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
294 /* 3 */ "globaldecl ::= vardecl", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
295 /* 4 */ "globaldecl ::= fundecl", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
296 /* 5 */ "vardecl ::= datatype ident ENDS", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
297 /* 6 */ "ident ::= IDENTIFIER", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
298 /* 7 */ "datatype ::= typename", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
299 /* 8 */ "datatype ::= datatype STAR", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
300 /* 9 */ "typename ::= KW_VOID", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
301 /* 10 */ "typename ::= KW_FLOAT", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
302 /* 11 */ "typename ::= KW_DOUBLE", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
303 /* 12 */ "typename ::= KW_LONG KW_DOUBLE", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
304 /* 13 */ "typename ::= baseint", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
305 /* 14 */ "typename ::= KW_UNSIGNED", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
306 /* 15 */ "typename ::= KW_SIGNED", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
307 /* 16 */ "typename ::= KW_SIGNED baseint", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
308 /* 17 */ "typename ::= KW_UNSIGNED baseint", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
309 /* 18 */ "baseint ::= KW_INT", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
310 /* 19 */ "baseint ::= KW_LONG", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
311 /* 20 */ "baseint ::= KW_LONG KW_INT", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
312 /* 21 */ "baseint ::= KW_LONG KW_LONG", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
313 /* 22 */ "baseint ::= KW_SHORT", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
314 /* 23 */ "baseint ::= KW_LONG KW_LONG KW_INT", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
315 /* 24 */ "baseint ::= KW_SHORT KW_INT", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
316 /* 25 */ "baseint ::= KW_CHAR", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
317 /* 26 */ "fundecl ::= datatype ident arglist statementblock", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
318 /* 27 */ "fundecl ::= datatype ident arglist ENDS", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
319 /* 28 */ "arglist ::= OPAREN CPAREN", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
320 /* 29 */ "statementblock ::= OBRACE CBRACE", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
321 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
322 #endif /* NDEBUG */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
323 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
324 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
325 #if YYSTACKDEPTH<=0 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
326 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
327 ** Try to increase the size of the parser stack. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
328 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
329 static void yyGrowStack(yyParser *p){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
330 int newSize; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
331 yyStackEntry *pNew; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
332 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
333 newSize = p->yystksz*2 + 100; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
334 pNew = realloc(p->yystack, newSize*sizeof(pNew[0])); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
335 if( pNew ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
336 p->yystack = pNew; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
337 p->yystksz = newSize; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
338 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
339 if( yyTraceFILE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
340 fprintf(yyTraceFILE,"%sStack grows to %d entries!\n", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
341 yyTracePrompt, p->yystksz); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
342 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
343 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
344 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
345 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
346 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
347 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
348 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
349 ** This function allocates a new parser. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
350 ** The only argument is a pointer to a function which works like |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
351 ** malloc. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
352 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
353 ** Inputs: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
354 ** A pointer to the function used to allocate memory. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
355 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
356 ** Outputs: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
357 ** A pointer to a parser. This pointer is used in subsequent calls |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
358 ** to Parse and ParseFree. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
359 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
360 void *ParseAlloc(void *(*mallocProc)(size_t)){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
361 yyParser *pParser; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
362 pParser = (yyParser*)(*mallocProc)( (size_t)sizeof(yyParser) ); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
363 if( pParser ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
364 pParser->yyidx = -1; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
365 #ifdef YYTRACKMAXSTACKDEPTH |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
366 pParser->yyidxMax = 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
367 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
368 #if YYSTACKDEPTH<=0 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
369 pParser->yystack = NULL; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
370 pParser->yystksz = 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
371 yyGrowStack(pParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
372 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
373 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
374 return pParser; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
375 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
376 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
377 /* The following function deletes the value associated with a |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
378 ** symbol. The symbol can be either a terminal or nonterminal. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
379 ** "yymajor" is the symbol code, and "yypminor" is a pointer to |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
380 ** the value. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
381 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
382 static void yy_destructor( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
383 yyParser *yypParser, /* The parser */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
384 YYCODETYPE yymajor, /* Type code for object to destroy */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
385 YYMINORTYPE *yypminor /* The object to be destroyed */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
386 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
387 ParseARG_FETCH; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
388 switch( yymajor ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
389 /* Here is inserted the actions which take place when a |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
390 ** terminal or non-terminal is destroyed. This can happen |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
391 ** when the symbol is popped from the stack during a |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
392 ** reduce or during error processing or when a parser is |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
393 ** being destroyed before it is finished parsing. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
394 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
395 ** Note: during a reduce, the only symbols destroyed are those |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
396 ** which appear on the RHS of the rule, but which are not used |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
397 ** inside the C code. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
398 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
399 /* TERMINAL Destructor */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
400 case 1: /* ENDS */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
401 case 2: /* IDENTIFIER */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
402 case 3: /* STAR */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
403 case 4: /* KW_VOID */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
404 case 5: /* KW_FLOAT */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
405 case 6: /* KW_DOUBLE */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
406 case 7: /* KW_LONG */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
407 case 8: /* KW_UNSIGNED */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
408 case 9: /* KW_SIGNED */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
409 case 10: /* KW_INT */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
410 case 11: /* KW_SHORT */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
411 case 12: /* KW_CHAR */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
412 case 13: /* OPAREN */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
413 case 14: /* CPAREN */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
414 case 15: /* OBRACE */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
415 case 16: /* CBRACE */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
416 { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
417 #line 10 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
418 tokendata_free((yypminor->yy0)); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
419 #line 420 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
420 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
421 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
422 default: break; /* If no destructor action specified: do nothing */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
423 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
424 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
425 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
426 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
427 ** Pop the parser's stack once. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
428 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
429 ** If there is a destructor routine associated with the token which |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
430 ** is popped from the stack, then call it. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
431 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
432 ** Return the major token number for the symbol popped. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
433 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
434 static int yy_pop_parser_stack(yyParser *pParser){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
435 YYCODETYPE yymajor; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
436 yyStackEntry *yytos = &pParser->yystack[pParser->yyidx]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
437 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
438 if( pParser->yyidx<0 ) return 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
439 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
440 if( yyTraceFILE && pParser->yyidx>=0 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
441 fprintf(yyTraceFILE,"%sPopping %s\n", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
442 yyTracePrompt, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
443 yyTokenName[yytos->major]); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
444 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
445 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
446 yymajor = yytos->major; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
447 yy_destructor(pParser, yymajor, &yytos->minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
448 pParser->yyidx--; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
449 return yymajor; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
450 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
451 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
452 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
453 ** Deallocate and destroy a parser. Destructors are all called for |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
454 ** all stack elements before shutting the parser down. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
455 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
456 ** Inputs: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
457 ** <ul> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
458 ** <li> A pointer to the parser. This should be a pointer |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
459 ** obtained from ParseAlloc. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
460 ** <li> A pointer to a function used to reclaim memory obtained |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
461 ** from malloc. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
462 ** </ul> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
463 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
464 void ParseFree( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
465 void *p, /* The parser to be deleted */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
466 void (*freeProc)(void*) /* Function used to reclaim memory */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
467 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
468 yyParser *pParser = (yyParser*)p; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
469 if( pParser==0 ) return; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
470 while( pParser->yyidx>=0 ) yy_pop_parser_stack(pParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
471 #if YYSTACKDEPTH<=0 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
472 free(pParser->yystack); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
473 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
474 (*freeProc)((void*)pParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
475 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
476 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
477 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
478 ** Return the peak depth of the stack for a parser. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
479 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
480 #ifdef YYTRACKMAXSTACKDEPTH |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
481 int ParseStackPeak(void *p){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
482 yyParser *pParser = (yyParser*)p; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
483 return pParser->yyidxMax; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
484 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
485 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
486 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
487 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
488 ** Find the appropriate action for a parser given the terminal |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
489 ** look-ahead token iLookAhead. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
490 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
491 ** If the look-ahead token is YYNOCODE, then check to see if the action is |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
492 ** independent of the look-ahead. If it is, return the action, otherwise |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
493 ** return YY_NO_ACTION. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
494 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
495 static int yy_find_shift_action( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
496 yyParser *pParser, /* The parser */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
497 YYCODETYPE iLookAhead /* The look-ahead token */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
498 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
499 int i; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
500 int stateno = pParser->yystack[pParser->yyidx].stateno; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
501 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
502 if( stateno>YY_SHIFT_COUNT |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
503 || (i = yy_shift_ofst[stateno])==YY_SHIFT_USE_DFLT ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
504 return yy_default[stateno]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
505 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
506 assert( iLookAhead!=YYNOCODE ); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
507 i += iLookAhead; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
508 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
509 if( iLookAhead>0 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
510 #ifdef YYFALLBACK |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
511 YYCODETYPE iFallback; /* Fallback token */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
512 if( iLookAhead<sizeof(yyFallback)/sizeof(yyFallback[0]) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
513 && (iFallback = yyFallback[iLookAhead])!=0 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
514 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
515 if( yyTraceFILE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
516 fprintf(yyTraceFILE, "%sFALLBACK %s => %s\n", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
517 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[iFallback]); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
518 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
519 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
520 return yy_find_shift_action(pParser, iFallback); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
521 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
522 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
523 #ifdef YYWILDCARD |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
524 { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
525 int j = i - iLookAhead + YYWILDCARD; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
526 if( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
527 #if YY_SHIFT_MIN+YYWILDCARD<0 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
528 j>=0 && |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
529 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
530 #if YY_SHIFT_MAX+YYWILDCARD>=YY_ACTTAB_COUNT |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
531 j<YY_ACTTAB_COUNT && |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
532 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
533 yy_lookahead[j]==YYWILDCARD |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
534 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
535 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
536 if( yyTraceFILE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
537 fprintf(yyTraceFILE, "%sWILDCARD %s => %s\n", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
538 yyTracePrompt, yyTokenName[iLookAhead], yyTokenName[YYWILDCARD]); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
539 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
540 #endif /* NDEBUG */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
541 return yy_action[j]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
542 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
543 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
544 #endif /* YYWILDCARD */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
545 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
546 return yy_default[stateno]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
547 }else{ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
548 return yy_action[i]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
549 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
550 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
551 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
552 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
553 ** Find the appropriate action for a parser given the non-terminal |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
554 ** look-ahead token iLookAhead. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
555 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
556 ** If the look-ahead token is YYNOCODE, then check to see if the action is |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
557 ** independent of the look-ahead. If it is, return the action, otherwise |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
558 ** return YY_NO_ACTION. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
559 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
560 static int yy_find_reduce_action( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
561 int stateno, /* Current state number */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
562 YYCODETYPE iLookAhead /* The look-ahead token */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
563 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
564 int i; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
565 #ifdef YYERRORSYMBOL |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
566 if( stateno>YY_REDUCE_COUNT ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
567 return yy_default[stateno]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
568 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
569 #else |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
570 assert( stateno<=YY_REDUCE_COUNT ); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
571 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
572 i = yy_reduce_ofst[stateno]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
573 assert( i!=YY_REDUCE_USE_DFLT ); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
574 assert( iLookAhead!=YYNOCODE ); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
575 i += iLookAhead; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
576 #ifdef YYERRORSYMBOL |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
577 if( i<0 || i>=YY_ACTTAB_COUNT || yy_lookahead[i]!=iLookAhead ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
578 return yy_default[stateno]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
579 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
580 #else |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
581 assert( i>=0 && i<YY_ACTTAB_COUNT ); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
582 assert( yy_lookahead[i]==iLookAhead ); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
583 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
584 return yy_action[i]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
585 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
586 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
587 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
588 ** The following routine is called if the stack overflows. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
589 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
590 static void yyStackOverflow(yyParser *yypParser, YYMINORTYPE *yypMinor){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
591 ParseARG_FETCH; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
592 yypParser->yyidx--; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
593 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
594 if( yyTraceFILE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
595 fprintf(yyTraceFILE,"%sStack Overflow!\n",yyTracePrompt); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
596 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
597 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
598 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
599 /* Here code is inserted which will execute if the parser |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
600 ** stack every overflows */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
601 #line 90 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
602 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
603 fprintf(stderr, "Parser stack overflow\n"); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
604 #line 605 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
605 ParseARG_STORE; /* Suppress warning about unused %extra_argument var */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
606 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
607 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
608 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
609 ** Perform a shift action. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
610 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
611 static void yy_shift( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
612 yyParser *yypParser, /* The parser to be shifted */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
613 int yyNewState, /* The new state to shift in */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
614 int yyMajor, /* The major token to shift in */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
615 YYMINORTYPE *yypMinor /* Pointer to the minor token to shift in */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
616 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
617 yyStackEntry *yytos; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
618 yypParser->yyidx++; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
619 #ifdef YYTRACKMAXSTACKDEPTH |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
620 if( yypParser->yyidx>yypParser->yyidxMax ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
621 yypParser->yyidxMax = yypParser->yyidx; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
622 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
623 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
624 #if YYSTACKDEPTH>0 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
625 if( yypParser->yyidx>=YYSTACKDEPTH ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
626 yyStackOverflow(yypParser, yypMinor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
627 return; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
628 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
629 #else |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
630 if( yypParser->yyidx>=yypParser->yystksz ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
631 yyGrowStack(yypParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
632 if( yypParser->yyidx>=yypParser->yystksz ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
633 yyStackOverflow(yypParser, yypMinor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
634 return; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
635 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
636 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
637 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
638 yytos = &yypParser->yystack[yypParser->yyidx]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
639 yytos->stateno = (YYACTIONTYPE)yyNewState; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
640 yytos->major = (YYCODETYPE)yyMajor; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
641 yytos->minor = *yypMinor; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
642 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
643 if( yyTraceFILE && yypParser->yyidx>0 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
644 int i; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
645 fprintf(yyTraceFILE,"%sShift %d\n",yyTracePrompt,yyNewState); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
646 fprintf(yyTraceFILE,"%sStack:",yyTracePrompt); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
647 for(i=1; i<=yypParser->yyidx; i++) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
648 fprintf(yyTraceFILE," %s",yyTokenName[yypParser->yystack[i].major]); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
649 fprintf(yyTraceFILE,"\n"); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
650 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
651 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
652 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
653 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
654 /* The following table contains information about every rule that |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
655 ** is used during the reduce. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
656 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
657 static const struct { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
658 YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
659 unsigned char nrhs; /* Number of right-hand side symbols in the rule */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
660 } yyRuleInfo[] = { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
661 { 18, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
662 { 19, 2 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
663 { 19, 0 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
664 { 20, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
665 { 20, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
666 { 21, 3 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
667 { 24, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
668 { 23, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
669 { 23, 2 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
670 { 25, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
671 { 25, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
672 { 25, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
673 { 25, 2 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
674 { 25, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
675 { 25, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
676 { 25, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
677 { 25, 2 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
678 { 25, 2 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
679 { 26, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
680 { 26, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
681 { 26, 2 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
682 { 26, 2 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
683 { 26, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
684 { 26, 3 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
685 { 26, 2 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
686 { 26, 1 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
687 { 22, 4 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
688 { 22, 4 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
689 { 27, 2 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
690 { 28, 2 }, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
691 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
692 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
693 static void yy_accept(yyParser*); /* Forward Declaration */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
694 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
695 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
696 ** Perform a reduce action and the shift that must immediately |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
697 ** follow the reduce. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
698 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
699 static void yy_reduce( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
700 yyParser *yypParser, /* The parser */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
701 int yyruleno /* Number of the rule by which to reduce */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
702 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
703 int yygoto; /* The next state */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
704 int yyact; /* The next action */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
705 YYMINORTYPE yygotominor; /* The LHS of the rule reduced */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
706 yyStackEntry *yymsp; /* The top of the parser's stack */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
707 int yysize; /* Amount to pop the stack */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
708 ParseARG_FETCH; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
709 yymsp = &yypParser->yystack[yypParser->yyidx]; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
710 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
711 if( yyTraceFILE && yyruleno>=0 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
712 && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
713 fprintf(yyTraceFILE, "%sReduce [%s].\n", yyTracePrompt, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
714 yyRuleName[yyruleno]); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
715 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
716 #endif /* NDEBUG */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
717 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
718 /* Silence complaints from purify about yygotominor being uninitialized |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
719 ** in some cases when it is copied into the stack after the following |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
720 ** switch. yygotominor is uninitialized when a rule reduces that does |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
721 ** not set the value of its left-hand side nonterminal. Leaving the |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
722 ** value of the nonterminal uninitialized is utterly harmless as long |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
723 ** as the value is never used. So really the only thing this code |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
724 ** accomplishes is to quieten purify. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
725 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
726 ** 2007-01-16: The wireshark project (www.wireshark.org) reports that |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
727 ** without this code, their parser segfaults. I'm not sure what there |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
728 ** parser is doing to make this happen. This is the second bug report |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
729 ** from wireshark this week. Clearly they are stressing Lemon in ways |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
730 ** that it has not been previously stressed... (SQLite ticket #2172) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
731 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
732 /*memset(&yygotominor, 0, sizeof(yygotominor));*/ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
733 yygotominor = yyzerominor; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
734 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
735 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
736 switch( yyruleno ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
737 /* Beginning here are the reduction cases. A typical example |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
738 ** follows: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
739 ** case 0: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
740 ** #line <lineno> <grammarfile> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
741 ** { ... } // User supplied code |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
742 ** #line <lineno> <thisfile> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
743 ** break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
744 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
745 case 0: /* program ::= rprogram */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
746 #line 14 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
747 { yygotominor.yy18 = yymsp[0].minor.yy18; pinfo -> parsetree = yygotominor.yy18; } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
748 #line 749 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
749 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
750 case 1: /* rprogram ::= rprogram globaldecl */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
751 #line 16 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
752 { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
753 yygotominor.yy18 = yymsp[-1].minor.yy18; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
754 node_addchild(yygotominor.yy18, yymsp[0].minor.yy18); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
755 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
756 #line 757 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
757 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
758 case 2: /* rprogram ::= */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
759 #line 20 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
760 { yygotominor.yy18 = node_create(NODE_PROGRAM); } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
761 #line 762 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
762 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
763 case 3: /* globaldecl ::= vardecl */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
764 case 4: /* globaldecl ::= fundecl */ yytestcase(yyruleno==4); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
765 case 7: /* datatype ::= typename */ yytestcase(yyruleno==7); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
766 case 13: /* typename ::= baseint */ yytestcase(yyruleno==13); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
767 #line 22 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
768 { yygotominor.yy18 = yymsp[0].minor.yy18; } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
769 #line 770 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
770 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
771 case 5: /* vardecl ::= datatype ident ENDS */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
772 #line 25 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
773 { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
774 yygotominor.yy18 = node_create(NODE_DECL, yymsp[-2].minor.yy18, yymsp[-1].minor.yy18); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
775 yy_destructor(yypParser,1,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
776 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
777 #line 778 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
778 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
779 case 6: /* ident ::= IDENTIFIER */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
780 #line 29 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
781 { yygotominor.yy18 = node_create(NODE_IDENT, yymsp[0].minor.yy0 -> strval); } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
782 #line 783 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
783 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
784 case 8: /* datatype ::= datatype STAR */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
785 #line 32 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
786 { yygotominor.yy18 = node_create(NODE_TYPE_PTR, yymsp[-1].minor.yy18); yy_destructor(yypParser,3,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
787 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
788 #line 789 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
789 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
790 case 9: /* typename ::= KW_VOID */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
791 #line 34 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
792 { yygotominor.yy18 = node_create(NODE_TYPE_VOID); yy_destructor(yypParser,4,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
793 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
794 #line 795 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
795 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
796 case 10: /* typename ::= KW_FLOAT */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
797 #line 35 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
798 { yygotominor.yy18 = node_create(NODE_TYPE_FLOAT); yy_destructor(yypParser,5,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
799 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
800 #line 801 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
801 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
802 case 11: /* typename ::= KW_DOUBLE */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
803 #line 36 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
804 { yygotominor.yy18 = node_create(NODE_TYPE_DOUBLE); yy_destructor(yypParser,6,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
805 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
806 #line 807 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
807 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
808 case 12: /* typename ::= KW_LONG KW_DOUBLE */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
809 #line 37 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
810 { yygotominor.yy18 = node_create(NODE_TYPE_LDOUBLE); yy_destructor(yypParser,7,&yymsp[-1].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
811 yy_destructor(yypParser,6,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
812 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
813 #line 814 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
814 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
815 case 14: /* typename ::= KW_UNSIGNED */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
816 #line 39 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
817 { yygotominor.yy18 = node_create(NODE_TYPE_UINT); yy_destructor(yypParser,8,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
818 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
819 #line 820 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
820 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
821 case 15: /* typename ::= KW_SIGNED */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
822 #line 40 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
823 { yygotominor.yy18 = node_create(NODE_TYPE_INT); yy_destructor(yypParser,9,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
824 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
825 #line 826 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
826 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
827 case 16: /* typename ::= KW_SIGNED baseint */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
828 #line 41 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
829 { yygotominor.yy18 = yymsp[0].minor.yy18; if (yygotominor.yy18 -> type == NODE_TYPE_CHAR) yygotominor.yy18 -> type = NODE_TYPE_SCHAR; yy_destructor(yypParser,9,&yymsp[-1].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
830 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
831 #line 832 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
832 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
833 case 17: /* typename ::= KW_UNSIGNED baseint */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
834 #line 42 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
835 { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
836 yygotominor.yy18 = yymsp[0].minor.yy18; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
837 switch (yygotominor.yy18 -> type) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
838 { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
839 case NODE_TYPE_CHAR: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
840 yygotominor.yy18 -> type = NODE_TYPE_UCHAR; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
841 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
842 case NODE_TYPE_SHORT: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
843 yygotominor.yy18 -> type = NODE_TYPE_USHORT; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
844 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
845 case NODE_TYPE_INT: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
846 yygotominor.yy18 -> type = NODE_TYPE_UINT; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
847 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
848 case NODE_TYPE_LONG: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
849 yygotominor.yy18 -> type = NODE_TYPE_ULONG; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
850 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
851 case NODE_TYPE_LONGLONG: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
852 yygotominor.yy18 -> type = NODE_TYPE_ULONGLONG; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
853 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
854 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
855 yy_destructor(yypParser,8,&yymsp[-1].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
856 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
857 #line 858 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
858 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
859 case 18: /* baseint ::= KW_INT */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
860 #line 64 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
861 { yygotominor.yy18 = node_create(NODE_TYPE_INT); yy_destructor(yypParser,10,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
862 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
863 #line 864 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
864 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
865 case 19: /* baseint ::= KW_LONG */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
866 #line 65 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
867 { yygotominor.yy18 = node_create(NODE_TYPE_LONG); yy_destructor(yypParser,7,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
868 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
869 #line 870 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
870 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
871 case 20: /* baseint ::= KW_LONG KW_INT */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
872 #line 66 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
873 { yygotominor.yy18 = node_create(NODE_TYPE_LONG); yy_destructor(yypParser,7,&yymsp[-1].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
874 yy_destructor(yypParser,10,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
875 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
876 #line 877 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
877 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
878 case 21: /* baseint ::= KW_LONG KW_LONG */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
879 #line 67 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
880 { yygotominor.yy18 = node_create(NODE_TYPE_LONGLONG); yy_destructor(yypParser,7,&yymsp[-1].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
881 yy_destructor(yypParser,7,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
882 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
883 #line 884 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
884 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
885 case 22: /* baseint ::= KW_SHORT */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
886 #line 68 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
887 { yygotominor.yy18 = node_create(NODE_TYPE_SHORT); yy_destructor(yypParser,11,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
888 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
889 #line 890 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
890 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
891 case 23: /* baseint ::= KW_LONG KW_LONG KW_INT */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
892 #line 69 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
893 { yygotominor.yy18 = node_create(NODE_TYPE_LONGLONG); yy_destructor(yypParser,7,&yymsp[-2].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
894 yy_destructor(yypParser,7,&yymsp[-1].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
895 yy_destructor(yypParser,10,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
896 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
897 #line 898 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
898 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
899 case 24: /* baseint ::= KW_SHORT KW_INT */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
900 #line 70 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
901 { yygotominor.yy18 = node_create(NODE_TYPE_SHORT); yy_destructor(yypParser,11,&yymsp[-1].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
902 yy_destructor(yypParser,10,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
903 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
904 #line 905 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
905 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
906 case 25: /* baseint ::= KW_CHAR */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
907 #line 71 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
908 { yygotominor.yy18 = node_create(NODE_TYPE_CHAR); yy_destructor(yypParser,12,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
909 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
910 #line 911 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
911 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
912 case 26: /* fundecl ::= datatype ident arglist statementblock */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
913 #line 74 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
914 { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
915 yygotominor.yy18 = node_create(NODE_FUNDEF, yymsp[-3].minor.yy18, yymsp[-2].minor.yy18, yymsp[-1].minor.yy18, yymsp[0].minor.yy18); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
916 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
917 #line 918 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
918 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
919 case 27: /* fundecl ::= datatype ident arglist ENDS */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
920 #line 78 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
921 { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
922 yygotominor.yy18 = node_create(NODE_FUNDECL, yymsp[-3].minor.yy18, yymsp[-2].minor.yy18, yymsp[-1].minor.yy18); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
923 yy_destructor(yypParser,1,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
924 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
925 #line 926 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
926 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
927 case 28: /* arglist ::= OPAREN CPAREN */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
928 #line 82 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
929 { yygotominor.yy18 = node_create(NODE_FUNARGS); yy_destructor(yypParser,13,&yymsp[-1].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
930 yy_destructor(yypParser,14,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
931 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
932 #line 933 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
933 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
934 case 29: /* statementblock ::= OBRACE CBRACE */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
935 #line 84 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
936 { yygotominor.yy18 = node_create(NODE_BLOCK); yy_destructor(yypParser,15,&yymsp[-1].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
937 yy_destructor(yypParser,16,&yymsp[0].minor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
938 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
939 #line 940 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
940 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
941 default: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
942 break; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
943 }; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
944 yygoto = yyRuleInfo[yyruleno].lhs; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
945 yysize = yyRuleInfo[yyruleno].nrhs; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
946 yypParser->yyidx -= yysize; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
947 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
948 if( yyact < YYNSTATE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
949 #ifdef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
950 /* If we are not debugging and the reduce action popped at least |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
951 ** one element off the stack, then we can push the new element back |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
952 ** onto the stack here, and skip the stack overflow test in yy_shift(). |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
953 ** That gives a significant speed improvement. */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
954 if( yysize ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
955 yypParser->yyidx++; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
956 yymsp -= yysize-1; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
957 yymsp->stateno = (YYACTIONTYPE)yyact; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
958 yymsp->major = (YYCODETYPE)yygoto; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
959 yymsp->minor = yygotominor; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
960 }else |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
961 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
962 { |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
963 yy_shift(yypParser,yyact,yygoto,&yygotominor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
964 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
965 }else{ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
966 assert( yyact == YYNSTATE + YYNRULE + 1 ); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
967 yy_accept(yypParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
968 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
969 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
970 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
971 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
972 ** The following code executes when the parse fails |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
973 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
974 #ifndef YYNOERRORRECOVERY |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
975 static void yy_parse_failed( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
976 yyParser *yypParser /* The parser */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
977 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
978 ParseARG_FETCH; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
979 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
980 if( yyTraceFILE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
981 fprintf(yyTraceFILE,"%sFail!\n",yyTracePrompt); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
982 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
983 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
984 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
985 /* Here code is inserted which will be executed whenever the |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
986 ** parser fails */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
987 #line 86 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
988 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
989 fprintf(stderr, "Parse error\n"); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
990 #line 991 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
991 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
992 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
993 #endif /* YYNOERRORRECOVERY */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
994 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
995 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
996 ** The following code executes when a syntax error first occurs. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
997 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
998 static void yy_syntax_error( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
999 yyParser *yypParser, /* The parser */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1000 int yymajor, /* The major type of the error token */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1001 YYMINORTYPE yyminor /* The minor type of the error token */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1002 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1003 ParseARG_FETCH; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1004 #define TOKEN (yyminor.yy0) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1005 #line 94 "lwcc/parse_c.y" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1006 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1007 fprintf(stderr, "Undexpected token %d: ", TOKEN -> tokid); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1008 tokendata_print(stderr, TOKEN); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1009 #line 1010 "lwcc/parse_c.c" |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1010 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1011 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1012 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1013 /* |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1014 ** The following is executed when the parser accepts |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1015 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1016 static void yy_accept( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1017 yyParser *yypParser /* The parser */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1018 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1019 ParseARG_FETCH; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1020 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1021 if( yyTraceFILE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1022 fprintf(yyTraceFILE,"%sAccept!\n",yyTracePrompt); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1023 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1024 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1025 while( yypParser->yyidx>=0 ) yy_pop_parser_stack(yypParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1026 /* Here code is inserted which will be executed whenever the |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1027 ** parser accepts */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1028 ParseARG_STORE; /* Suppress warning about unused %extra_argument variable */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1029 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1030 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1031 /* The main parser program. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1032 ** The first argument is a pointer to a structure obtained from |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1033 ** "ParseAlloc" which describes the current state of the parser. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1034 ** The second argument is the major token number. The third is |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1035 ** the minor token. The fourth optional argument is whatever the |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1036 ** user wants (and specified in the grammar) and is available for |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1037 ** use by the action routines. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1038 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1039 ** Inputs: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1040 ** <ul> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1041 ** <li> A pointer to the parser (an opaque structure.) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1042 ** <li> The major token number. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1043 ** <li> The minor token number. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1044 ** <li> An option argument of a grammar-specified type. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1045 ** </ul> |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1046 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1047 ** Outputs: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1048 ** None. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1049 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1050 void Parse( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1051 void *yyp, /* The parser */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1052 int yymajor, /* The major token code number */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1053 ParseTOKENTYPE yyminor /* The value for the token */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1054 ParseARG_PDECL /* Optional %extra_argument parameter */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1055 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1056 YYMINORTYPE yyminorunion; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1057 int yyact; /* The parser action. */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1058 int yyendofinput; /* True if we are at the end of input */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1059 #ifdef YYERRORSYMBOL |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1060 int yyerrorhit = 0; /* True if yymajor has invoked an error */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1061 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1062 yyParser *yypParser; /* The parser */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1063 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1064 /* (re)initialize the parser, if necessary */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1065 yypParser = (yyParser*)yyp; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1066 if( yypParser->yyidx<0 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1067 #if YYSTACKDEPTH<=0 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1068 if( yypParser->yystksz <=0 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1069 /*memset(&yyminorunion, 0, sizeof(yyminorunion));*/ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1070 yyminorunion = yyzerominor; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1071 yyStackOverflow(yypParser, &yyminorunion); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1072 return; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1073 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1074 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1075 yypParser->yyidx = 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1076 yypParser->yyerrcnt = -1; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1077 yypParser->yystack[0].stateno = 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1078 yypParser->yystack[0].major = 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1079 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1080 yyminorunion.yy0 = yyminor; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1081 yyendofinput = (yymajor==0); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1082 ParseARG_STORE; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1083 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1084 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1085 if( yyTraceFILE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1086 fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1087 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1088 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1089 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1090 do{ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1091 yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1092 if( yyact<YYNSTATE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1093 assert( !yyendofinput ); /* Impossible to shift the $ token */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1094 yy_shift(yypParser,yyact,yymajor,&yyminorunion); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1095 yypParser->yyerrcnt--; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1096 yymajor = YYNOCODE; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1097 }else if( yyact < YYNSTATE + YYNRULE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1098 yy_reduce(yypParser,yyact-YYNSTATE); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1099 }else{ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1100 assert( yyact == YY_ERROR_ACTION ); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1101 #ifdef YYERRORSYMBOL |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1102 int yymx; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1103 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1104 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1105 if( yyTraceFILE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1106 fprintf(yyTraceFILE,"%sSyntax Error!\n",yyTracePrompt); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1107 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1108 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1109 #ifdef YYERRORSYMBOL |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1110 /* A syntax error has occurred. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1111 ** The response to an error depends upon whether or not the |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1112 ** grammar defines an error token "ERROR". |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1113 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1114 ** This is what we do if the grammar does define ERROR: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1115 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1116 ** * Call the %syntax_error function. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1117 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1118 ** * Begin popping the stack until we enter a state where |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1119 ** it is legal to shift the error symbol, then shift |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1120 ** the error symbol. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1121 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1122 ** * Set the error count to three. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1123 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1124 ** * Begin accepting and shifting new tokens. No new error |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1125 ** processing will occur until three tokens have been |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1126 ** shifted successfully. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1127 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1128 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1129 if( yypParser->yyerrcnt<0 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1130 yy_syntax_error(yypParser,yymajor,yyminorunion); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1131 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1132 yymx = yypParser->yystack[yypParser->yyidx].major; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1133 if( yymx==YYERRORSYMBOL || yyerrorhit ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1134 #ifndef NDEBUG |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1135 if( yyTraceFILE ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1136 fprintf(yyTraceFILE,"%sDiscard input token %s\n", |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1137 yyTracePrompt,yyTokenName[yymajor]); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1138 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1139 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1140 yy_destructor(yypParser, (YYCODETYPE)yymajor,&yyminorunion); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1141 yymajor = YYNOCODE; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1142 }else{ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1143 while( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1144 yypParser->yyidx >= 0 && |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1145 yymx != YYERRORSYMBOL && |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1146 (yyact = yy_find_reduce_action( |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1147 yypParser->yystack[yypParser->yyidx].stateno, |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1148 YYERRORSYMBOL)) >= YYNSTATE |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1149 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1150 yy_pop_parser_stack(yypParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1151 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1152 if( yypParser->yyidx < 0 || yymajor==0 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1153 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1154 yy_parse_failed(yypParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1155 yymajor = YYNOCODE; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1156 }else if( yymx!=YYERRORSYMBOL ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1157 YYMINORTYPE u2; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1158 u2.YYERRSYMDT = 0; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1159 yy_shift(yypParser,yyact,YYERRORSYMBOL,&u2); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1160 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1161 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1162 yypParser->yyerrcnt = 3; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1163 yyerrorhit = 1; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1164 #elif defined(YYNOERRORRECOVERY) |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1165 /* If the YYNOERRORRECOVERY macro is defined, then do not attempt to |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1166 ** do any kind of error recovery. Instead, simply invoke the syntax |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1167 ** error routine and continue going as if nothing had happened. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1168 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1169 ** Applications can set this macro (for example inside %include) if |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1170 ** they intend to abandon the parse upon the first syntax error seen. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1171 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1172 yy_syntax_error(yypParser,yymajor,yyminorunion); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1173 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1174 yymajor = YYNOCODE; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1175 |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1176 #else /* YYERRORSYMBOL is not defined */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1177 /* This is what we do if the grammar does not define ERROR: |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1178 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1179 ** * Report an error message, and throw away the input token. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1180 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1181 ** * If the input token is $, then fail the parse. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1182 ** |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1183 ** As before, subsequent error messages are suppressed until |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1184 ** three input tokens have been successfully shifted. |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1185 */ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1186 if( yypParser->yyerrcnt<=0 ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1187 yy_syntax_error(yypParser,yymajor,yyminorunion); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1188 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1189 yypParser->yyerrcnt = 3; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1190 yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1191 if( yyendofinput ){ |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1192 yy_parse_failed(yypParser); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1193 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1194 yymajor = YYNOCODE; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1195 #endif |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1196 } |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1197 }while( yymajor!=YYNOCODE && yypParser->yyidx>=0 ); |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1198 return; |
a3e277c58df9
Checkpoint parser development for lwcc
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1199 } |