]> git.saurik.com Git - bison.git/blame - src/lalr.h
Simplify y.tab.c when location tracking is disabled.
[bison.git] / src / lalr.h
CommitLineData
742e4900 1/* Compute lookahead criteria for bison,
779e7ceb 2
db34f798
JD
3 Copyright (C) 1984, 1986, 1989, 2000, 2002, 2004, 2006, 2007, 2009
4 Free Software Foundation, Inc.
720d742f
AD
5
6 This file is part of Bison, the GNU Compiler Compiler.
7
f16b0819 8 This program is free software: you can redistribute it and/or modify
720d742f 9 it under the terms of the GNU General Public License as published by
f16b0819
PE
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
720d742f 12
f16b0819 13 This program is distributed in the hope that it will be useful,
720d742f
AD
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
f16b0819 19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
720d742f
AD
20
21#ifndef LALR_H_
22# define LALR_H_
23
b78d8c23
PE
24# include <bitset.h>
25# include <bitsetv.h>
a70083a3 26
b0299a2e
AD
27/* Import the definition of RULE_T. */
28# include "gram.h"
a70083a3 29
b78d8c23
PE
30/* Import the definition of CORE, TRANSITIONS and REDUCTIONS. */
31# include "state.h"
32
2073e1b6
AD
33
34/** Build the LALR(1) automaton.
35
36 Compute how to make the finite state machine deterministic; find
742e4900 37 which rules need lookahead in each state, and which lookahead
2073e1b6 38 tokens they accept.
720d742f 39
db34f798
JD
40 Also builds:
41 - #goto_map
42 - #from_state
43 - #to_state
44 - #goto_follows
2073e1b6 45*/
d33cb3ae 46void lalr (void);
720d742f 47
db34f798
JD
48/**
49 * Set #nLA and allocate all reduction lookahead sets. Normally invoked by
50 * #lalr.
51 */
52void initialize_LA (void);
53
54/**
55 * Build only:
56 * - #goto_map
57 * - #from_state
58 * - #to_state
59 * Normally invoked by #lalr.
60 */
61void set_goto_map (void);
62
5967f0cf
JD
63/**
64 * Update state numbers recorded in #goto_map, #from_state, and #to_state such
65 * that:
66 * - \c nstates_old is the old number of states.
67 * - Where \c i is the old state number, <tt>old_to_new[i]</tt> is either:
68 * - \c nstates_old if state \c i is removed because it is unreachable.
69 * Thus, remove all goto entries involving this state.
70 * - The new state number.
71 */
72void lalr_update_state_numbers (state_number old_to_new[],
73 state_number nstates_old);
74
3325ddc4 75
2073e1b6 76/** Release the information related to lookahead tokens.
3325ddc4 77
2073e1b6
AD
78 Can be performed once the action tables are computed. */
79void lalr_free (void);
720d742f 80
2073e1b6
AD
81typedef size_t goto_number;
82# define GOTO_NUMBER_MAXIMUM ((goto_number) -1)
720d742f 83
2073e1b6 84/** Index into #from_state and #to_state.
43591cec
AD
85
86 All the transitions that accept a particular variable are grouped
87 together and GOTO_MAP[I - NTOKENS] is the index in FROM_STATE and
88 TO_STATE of the first of them. */
b78d8c23 89extern goto_number *goto_map;
2073e1b6 90
db34f798
JD
91/** The size of #from_state and #to_state. */
92extern goto_number ngotos;
93
94/** State number which a transition leads from. */
b78d8c23 95extern state_number *from_state;
2073e1b6
AD
96
97/** State number it leads to. */
b78d8c23 98extern state_number *to_state;
720d742f 99
db34f798
JD
100/** Map a state/symbol pair into its numeric representation. */
101goto_number map_goto (state_number s0, symbol_number sym);
102
103/* goto_follows[i] is the set of tokens following goto i. */
104extern bitsetv goto_follows;
105
720d742f 106
720d742f 107#endif /* !LALR_H_ */