]> git.saurik.com Git - bison.git/blob - src/lalr.h
Avoid empty-if warnings.
[bison.git] / src / lalr.h
1 /* Compute lookahead criteria for bison,
2
3 Copyright (C) 1984, 1986, 1989, 2000, 2002, 2004, 2006, 2007 Free Software
4 Foundation, Inc.
5
6 This file is part of Bison, the GNU Compiler Compiler.
7
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.
12
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.
17
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/>. */
20
21 #ifndef LALR_H_
22 # define LALR_H_
23
24 # include <bitset.h>
25 # include <bitsetv.h>
26
27 /* Import the definition of RULE_T. */
28 # include "gram.h"
29
30 /* Import the definition of CORE, TRANSITIONS and REDUCTIONS. */
31 # include "state.h"
32
33
34 /** Build the LALR(1) automaton.
35
36 Compute how to make the finite state machine deterministic; find
37 which rules need lookahead in each state, and which lookahead
38 tokens they accept.
39
40 Builds:
41 - #goto_map
42 - #from_state
43 - #to_state
44 */
45 void lalr (void);
46
47 /**
48 * Update state numbers recorded in #goto_map, #from_state, and #to_state such
49 * that:
50 * - \c nstates_old is the old number of states.
51 * - Where \c i is the old state number, <tt>old_to_new[i]</tt> is either:
52 * - \c nstates_old if state \c i is removed because it is unreachable.
53 * Thus, remove all goto entries involving this state.
54 * - The new state number.
55 */
56 void lalr_update_state_numbers (state_number old_to_new[],
57 state_number nstates_old);
58
59
60 /** Release the information related to lookahead tokens.
61
62 Can be performed once the action tables are computed. */
63 void lalr_free (void);
64
65
66 typedef size_t goto_number;
67 # define GOTO_NUMBER_MAXIMUM ((goto_number) -1)
68
69 /** Index into #from_state and #to_state.
70
71 All the transitions that accept a particular variable are grouped
72 together and GOTO_MAP[I - NTOKENS] is the index in FROM_STATE and
73 TO_STATE of the first of them. */
74 extern goto_number *goto_map;
75
76 /** State number which a transition leads from. */
77 extern state_number *from_state;
78
79 /** State number it leads to. */
80 extern state_number *to_state;
81
82
83 #endif /* !LALR_H_ */