]> git.saurik.com Git - bison.git/blame - src/tables.h
build: look for Perl in configure.
[bison.git] / src / tables.h
CommitLineData
c6f1a33c 1/* Prepare the LALR and GLR parser tables.
6e30ede8 2
c932d613 3 Copyright (C) 2002, 2004, 2009-2012 Free Software Foundation, Inc.
c6f1a33c
AD
4
5 This file is part of Bison, the GNU Compiler Compiler.
6
f16b0819
PE
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.
c6f1a33c 11
f16b0819
PE
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.
c6f1a33c
AD
16
17 You should have received a copy of the GNU General Public License
f16b0819 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c6f1a33c
AD
19
20#ifndef TABLES_H_
21# define TABLES_H_
22
23# include "state.h"
24
20c1e2ad
AD
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
d5eb0826
JD
49 YYFINAL = the state number of the termination state.
50
51 YYTABLE = a vector filled with portions for different uses, found
e4bcae3c 52 via YYPACT and YYPGOTO, described below.
d5eb0826
JD
53
54 YYLAST ( = high) the number of the last element of YYTABLE, i.e.,
55 sizeof (YYTABLE) - 1.
56
57 YYCHECK = a vector indexed in parallel with YYTABLE. It indicates,
58 in a roundabout way, the bounds of the portion you are trying to
59 examine.
60
61 Suppose that the portion of YYTABLE starts at index P and the index
62 to be examined within the portion is I. Then if YYCHECK[P+I] != I,
63 I is outside the bounds of what is actually allocated, and the
64 default (from YYDEFACT or YYDEFGOTO) should be used. Otherwise,
65 YYTABLE[P+I] should be used.
66
620b5727
JD
67 YYDEFACT[S] = default reduction number in state s. Performed when
68 YYTABLE doesn't specify something else to do. Zero means the default
69 is an error.
20c1e2ad
AD
70
71 YYDEFGOTO[I] = default state to go to after a reduction of a rule
72 that generates variable NTOKENS + I, except when YYTABLE specifies
73 something else to do.
74
75 YYPACT[S] = index in YYTABLE of the portion describing state S.
77373efa
JD
76 The lookahead token's number, I, is used to index that portion of
77 YYTABLE to find out what action to perform.
78
79 If YYPACT[S] == YYPACT_NINF, if YYPACT[S] + I is outside the bounds
d5eb0826
JD
80 of YYTABLE (from 0 to YYLAST), or I is outside the bounds for portion
81 S (that is, YYCHECK[YYPACT[S] + I] != I), then the default action
82 (that is, YYDEFACT[S]) should be used instead of YYTABLE. Otherwise,
83 the value YYTABLE[YYPACT[S] + I] should be used even if
77373efa 84 YYPACT[S] < 0.
20c1e2ad
AD
85
86 If the value in YYTABLE is positive, we shift the token and go to
87 that state.
88
89 If the value is negative, it is minus a rule number to reduce by.
90
e4bcae3c 91 If the value is YYTABLE_NINF, it's a syntax error.
77373efa 92
20c1e2ad
AD
93 YYPGOTO[I] = the index in YYTABLE of the portion describing what to
94 do after reducing a rule that derives variable I + NTOKENS. This
95 portion is indexed by the parser state number, S, as of before the
d5eb0826
JD
96 text for this nonterminal was read.
97
98 If YYPGOTO[I] + S is outside the bounds of YYTABLE (from 0 to YYLAST)
99 or if S is outside the bounds of the portion for I (that is,
100 YYCHECK[YYPGOTO[I] + S] != S), then the default state (that is,
101 YYDEFGOTO[I]) should be used instead of YYTABLE. Otherwise,
102 YYTABLE[YYPGOTO[I] + S] is the state to go to even if YYPGOTO[I] < 0.
e4bcae3c
JD
103
104 When the above YYPACT, YYPGOTO, and YYCHECK tests determine that a
105 value from YYTABLE should be used, that value is never zero, so it is
106 useless to check for zero. When those tests indicate that the value
107 from YYDEFACT or YYDEFGOTO should be used instead, the value from
108 YYTABLE *might* be zero, which, as a consequence of the way in which
109 the tables are constructed, also happens to indicate that YYDEFACT or
110 YYDEFGOTO should be used. However, the YYTABLE value cannot be
111 trusted when the YYDEFACT or YYDEFGOTO value should be used. In
112 summary, forget about zero values in YYTABLE.
d5eb0826 113*/
20c1e2ad 114
c6f1a33c
AD
115extern int nvectors;
116
3671fb84
PE
117typedef int base_number;
118extern base_number *base;
c6f1a33c 119/* A distinguished value of BASE, negative infinite. During the
3671fb84 120 computation equals to BASE_MINIMUM, later mapped to BASE_NINF to
c6f1a33c 121 keep parser tables small. */
3671fb84 122extern base_number base_ninf;
c6f1a33c
AD
123
124extern unsigned int *conflict_table;
125extern unsigned int *conflict_list;
126extern int conflict_list_cnt;
127
3671fb84
PE
128extern base_number *table;
129extern base_number *check;
6e649e65 130/* The value used in TABLE to denote explicit syntax errors
c6f1a33c 131 (%nonassoc), a negative infinite. */
3671fb84 132extern base_number table_ninf;
c6f1a33c 133
3671fb84
PE
134extern state_number *yydefgoto;
135extern rule_number *yydefact;
c6f1a33c
AD
136extern int high;
137
d33cb3ae
PE
138void tables_generate (void);
139void tables_free (void);
c6f1a33c
AD
140
141#endif /* !TABLES_H_ */