]>
git.saurik.com Git - bison.git/blob - src/lalr.h
1 /* Compute lookahead criteria for bison,
3 Copyright (C) 1984, 1986, 1989, 2000, 2002, 2004, 2006, 2007, 2009
4 Free Software Foundation, Inc.
6 This file is part of Bison, the GNU Compiler Compiler.
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
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.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 /* Import the definition of RULE_T. */
30 /* Import the definition of CORE, TRANSITIONS and REDUCTIONS. */
34 /** Build the LALR(1) automaton.
36 Compute how to make the finite state machine deterministic; find
37 which rules need lookahead in each state, and which lookahead
49 * Set #nLA and allocate all reduction lookahead sets. Normally invoked by
52 void initialize_LA (void);
59 * Normally invoked by #lalr.
61 void set_goto_map (void);
64 * Update state numbers recorded in #goto_map, #from_state, and #to_state such
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.
72 void lalr_update_state_numbers (state_number old_to_new
[],
73 state_number nstates_old
);
76 /** Release the information related to lookahead tokens.
78 Can be performed once the action tables are computed. */
79 void lalr_free (void);
81 typedef size_t goto_number
;
82 # define GOTO_NUMBER_MAXIMUM ((goto_number) -1)
84 /** Index into #from_state and #to_state.
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. */
89 extern goto_number
*goto_map
;
91 /** The size of #from_state and #to_state. */
92 extern goto_number ngotos
;
94 /** State number which a transition leads from. */
95 extern state_number
*from_state
;
97 /** State number it leads to. */
98 extern state_number
*to_state
;
100 /** Map a state/symbol pair into its numeric representation. */
101 goto_number
map_goto (state_number s0
, symbol_number sym
);
103 /* goto_follows[i] is the set of tokens following goto i. */
104 extern bitsetv goto_follows
;
107 #endif /* !LALR_H_ */