]>
Commit | Line | Data |
---|---|---|
c6f1a33c | 1 | /* Prepare the LALR and GLR parser tables. |
8dd162d3 | 2 | Copyright (C) 2002, 2004 Free Software Foundation, Inc. |
c6f1a33c AD |
3 | |
4 | This file is part of Bison, the GNU Compiler Compiler. | |
5 | ||
f16b0819 PE |
6 | This program is free software: you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | |
8 | the Free Software Foundation, either version 3 of the License, or | |
9 | (at your option) any later version. | |
c6f1a33c | 10 | |
f16b0819 PE |
11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
c6f1a33c AD |
15 | |
16 | You should have received a copy of the GNU General Public License | |
f16b0819 | 17 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c6f1a33c AD |
18 | |
19 | #ifndef TABLES_H_ | |
20 | # define TABLES_H_ | |
21 | ||
22 | # include "state.h" | |
23 | ||
20c1e2ad AD |
24 | /* The parser tables consist of these tables. |
25 | ||
26 | YYTRANSLATE = vector mapping yylex's token numbers into bison's | |
27 | token numbers. | |
28 | ||
29 | YYTNAME = vector of string-names indexed by bison token number. | |
30 | ||
31 | YYTOKNUM = vector of yylex token numbers corresponding to entries | |
32 | in YYTNAME. | |
33 | ||
34 | YYRLINE = vector of line-numbers of all rules. For yydebug | |
35 | printouts. | |
36 | ||
37 | YYRHS = vector of items of all rules. This is exactly what RITEMS | |
38 | contains. For yydebug and for semantic parser. | |
39 | ||
40 | YYPRHS[R] = index in YYRHS of first item for rule R. | |
41 | ||
42 | YYR1[R] = symbol number of symbol that rule R derives. | |
43 | ||
44 | YYR2[R] = number of symbols composing right hand side of rule R. | |
45 | ||
46 | YYSTOS[S] = the symbol number of the symbol that leads to state S. | |
47 | ||
48 | YYDEFACT[S] = default rule to reduce with in state s, when YYTABLE | |
49 | doesn't specify something else to do. Zero means the default is an | |
50 | error. | |
51 | ||
52 | YYDEFGOTO[I] = default state to go to after a reduction of a rule | |
53 | that generates variable NTOKENS + I, except when YYTABLE specifies | |
54 | something else to do. | |
55 | ||
56 | YYPACT[S] = index in YYTABLE of the portion describing state S. | |
742e4900 | 57 | The lookahead token's type is used to index that portion to find |
20c1e2ad AD |
58 | out what to do. |
59 | ||
60 | If the value in YYTABLE is positive, we shift the token and go to | |
61 | that state. | |
62 | ||
63 | If the value is negative, it is minus a rule number to reduce by. | |
64 | ||
65 | If the value is zero, the default action from YYDEFACT[S] is used. | |
66 | ||
67 | YYPGOTO[I] = the index in YYTABLE of the portion describing what to | |
68 | do after reducing a rule that derives variable I + NTOKENS. This | |
69 | portion is indexed by the parser state number, S, as of before the | |
70 | text for this nonterminal was read. The value from YYTABLE is the | |
71 | state to go to if the corresponding value in YYCHECK is S. | |
72 | ||
73 | YYTABLE = a vector filled with portions for different uses, found | |
74 | via YYPACT and YYPGOTO. | |
75 | ||
76 | YYCHECK = a vector indexed in parallel with YYTABLE. It indicates, | |
77 | in a roundabout way, the bounds of the portion you are trying to | |
78 | examine. | |
79 | ||
80 | Suppose that the portion of YYTABLE starts at index P and the index | |
81 | to be examined within the portion is I. Then if YYCHECK[P+I] != I, | |
82 | I is outside the bounds of what is actually allocated, and the | |
83 | default (from YYDEFACT or YYDEFGOTO) should be used. Otherwise, | |
84 | YYTABLE[P+I] should be used. | |
85 | ||
39912f52 AD |
86 | YYFINAL = the state number of the termination state. |
87 | ||
88 | YYLAST ( = high) the number of the last element of YYTABLE, i.e., | |
89 | sizeof (YYTABLE) - 1. */ | |
20c1e2ad | 90 | |
c6f1a33c AD |
91 | extern int nvectors; |
92 | ||
3671fb84 PE |
93 | typedef int base_number; |
94 | extern base_number *base; | |
c6f1a33c | 95 | /* A distinguished value of BASE, negative infinite. During the |
3671fb84 | 96 | computation equals to BASE_MINIMUM, later mapped to BASE_NINF to |
c6f1a33c | 97 | keep parser tables small. */ |
3671fb84 | 98 | extern base_number base_ninf; |
c6f1a33c AD |
99 | |
100 | extern unsigned int *conflict_table; | |
101 | extern unsigned int *conflict_list; | |
102 | extern int conflict_list_cnt; | |
103 | ||
3671fb84 PE |
104 | extern base_number *table; |
105 | extern base_number *check; | |
6e649e65 | 106 | /* The value used in TABLE to denote explicit syntax errors |
c6f1a33c | 107 | (%nonassoc), a negative infinite. */ |
3671fb84 | 108 | extern base_number table_ninf; |
c6f1a33c | 109 | |
3671fb84 PE |
110 | extern state_number *yydefgoto; |
111 | extern rule_number *yydefact; | |
c6f1a33c AD |
112 | extern int high; |
113 | ||
d33cb3ae PE |
114 | void tables_generate (void); |
115 | void tables_free (void); | |
c6f1a33c AD |
116 | |
117 | #endif /* !TABLES_H_ */ |