]>
git.saurik.com Git - bison.git/blob - src/tables.h
b21fa7b0b0079520ee130bec35339d440c4bd749
1 /* Prepare the LALR and GLR parser tables.
2 Copyright (C) 2002, 2004, 2009 Free Software Foundation, Inc.
4 This file is part of Bison, the GNU Compiler Compiler.
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.
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.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 /* The parser tables consist of these tables.
26 YYTRANSLATE = vector mapping yylex's token numbers into bison's
29 YYTNAME = vector of string-names indexed by bison token number.
31 YYTOKNUM = vector of yylex token numbers corresponding to entries
34 YYRLINE = vector of line-numbers of all rules. For yydebug
37 YYRHS = vector of items of all rules. This is exactly what RITEMS
38 contains. For yydebug and for semantic parser.
40 YYPRHS[R] = index in YYRHS of first item for rule R.
42 YYR1[R] = symbol number of symbol that rule R derives.
44 YYR2[R] = number of symbols composing right hand side of rule R.
46 YYSTOS[S] = the symbol number of the symbol that leads to state S.
48 YYDEFACT[S] = default reduction number in state s. Performed when
49 YYTABLE doesn't specify something else to do. Zero means the default
52 YYDEFGOTO[I] = default state to go to after a reduction of a rule
53 that generates variable NTOKENS + I, except when YYTABLE specifies
56 YYPACT[S] = index in YYTABLE of the portion describing state S.
57 The lookahead token's number, I, is used to index that portion of
58 YYTABLE to find out what action to perform.
60 If YYPACT[S] == YYPACT_NINF, if YYPACT[S] + I is outside the bounds
61 of YYTABLE (from 0 to YYLAST), or if YYCHECK indicates that I is
62 outside the bounds of the portion for S, then the default action
63 (from YYDEFACT and YYDEFGOTO) should be used instead of YYTABLE.
64 Otherwise, the value YYTABLE[YYPACT[S] + I] should be used even if
67 If the value in YYTABLE is positive, we shift the token and go to
70 If the value is negative, it is minus a rule number to reduce by.
72 If the value is zero, the default action from YYDEFACT[S] is used.
74 If the value is YYTABLE_NINF, it's a syntax error.
76 YYPGOTO[I] = the index in YYTABLE of the portion describing what to
77 do after reducing a rule that derives variable I + NTOKENS. This
78 portion is indexed by the parser state number, S, as of before the
79 text for this nonterminal was read. The value from YYTABLE is the
80 state to go to if the corresponding value in YYCHECK is S.
82 YYTABLE = a vector filled with portions for different uses, found
83 via YYPACT and YYPGOTO.
85 YYCHECK = a vector indexed in parallel with YYTABLE. It indicates,
86 in a roundabout way, the bounds of the portion you are trying to
89 Suppose that the portion of YYTABLE starts at index P and the index
90 to be examined within the portion is I. Then if YYCHECK[P+I] != I,
91 I is outside the bounds of what is actually allocated, and the
92 default (from YYDEFACT or YYDEFGOTO) should be used. Otherwise,
93 YYTABLE[P+I] should be used.
95 YYFINAL = the state number of the termination state.
97 YYLAST ( = high) the number of the last element of YYTABLE, i.e.,
98 sizeof (YYTABLE) - 1. */
102 typedef int base_number
;
103 extern base_number
*base
;
104 /* A distinguished value of BASE, negative infinite. During the
105 computation equals to BASE_MINIMUM, later mapped to BASE_NINF to
106 keep parser tables small. */
107 extern base_number base_ninf
;
109 extern unsigned int *conflict_table
;
110 extern unsigned int *conflict_list
;
111 extern int conflict_list_cnt
;
113 extern base_number
*table
;
114 extern base_number
*check
;
115 /* The value used in TABLE to denote explicit syntax errors
116 (%nonassoc), a negative infinite. */
117 extern base_number table_ninf
;
119 extern state_number
*yydefgoto
;
120 extern rule_number
*yydefact
;
123 void tables_generate (void);
124 void tables_free (void);
126 #endif /* !TABLES_H_ */