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