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