]> git.saurik.com Git - bison.git/blame - src/lalr.h
* NEWS (2.3a+): Mention yesterday's state-removal change.
[bison.git] / src / lalr.h
CommitLineData
742e4900 1/* Compute lookahead criteria for bison,
779e7ceb 2
75ad86ee 3 Copyright (C) 1984, 1986, 1989, 2000, 2002, 2004, 2006, 2007 Free Software
779e7ceb 4 Foundation, Inc.
720d742f
AD
5
6 This file is part of Bison, the GNU Compiler Compiler.
7
8 Bison 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 2, or (at your option)
11 any later version.
12
13 Bison 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.
17
18 You should have received a copy of the GNU General Public License
19 along with Bison; see the file COPYING. If not, write to
0fb669f9
PE
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
720d742f
AD
22
23#ifndef LALR_H_
24# define LALR_H_
25
b78d8c23
PE
26# include <bitset.h>
27# include <bitsetv.h>
a70083a3 28
b0299a2e
AD
29/* Import the definition of RULE_T. */
30# include "gram.h"
a70083a3 31
b78d8c23
PE
32/* Import the definition of CORE, TRANSITIONS and REDUCTIONS. */
33# include "state.h"
34
2073e1b6
AD
35
36/** Build the LALR(1) automaton.
37
38 Compute how to make the finite state machine deterministic; find
742e4900 39 which rules need lookahead in each state, and which lookahead
2073e1b6 40 tokens they accept.
720d742f 41
2073e1b6
AD
42 Builds:
43 - #goto_map
44 - #from_state
45 - #to_state
46*/
d33cb3ae 47void lalr (void);
720d742f 48
5967f0cf
JD
49/**
50 * Update state numbers recorded in #goto_map, #from_state, and #to_state such
51 * that:
52 * - \c nstates_old is the old number of states.
53 * - Where \c i is the old state number, <tt>old_to_new[i]</tt> is either:
54 * - \c nstates_old if state \c i is removed because it is unreachable.
55 * Thus, remove all goto entries involving this state.
56 * - The new state number.
57 */
58void lalr_update_state_numbers (state_number old_to_new[],
59 state_number nstates_old);
60
3325ddc4 61
2073e1b6 62/** Release the information related to lookahead tokens.
3325ddc4 63
2073e1b6
AD
64 Can be performed once the action tables are computed. */
65void lalr_free (void);
720d742f 66
720d742f 67
2073e1b6
AD
68typedef size_t goto_number;
69# define GOTO_NUMBER_MAXIMUM ((goto_number) -1)
720d742f 70
2073e1b6 71/** Index into #from_state and #to_state.
43591cec
AD
72
73 All the transitions that accept a particular variable are grouped
74 together and GOTO_MAP[I - NTOKENS] is the index in FROM_STATE and
75 TO_STATE of the first of them. */
b78d8c23 76extern goto_number *goto_map;
2073e1b6
AD
77
78/** State number which a transition leads from. */
b78d8c23 79extern state_number *from_state;
2073e1b6
AD
80
81/** State number it leads to. */
b78d8c23 82extern state_number *to_state;
720d742f 83
720d742f 84
720d742f 85#endif /* !LALR_H_ */