glr2.cc: require C++11
[bison.git] / src / reader.h
blob6b2f29a9ccfd1baa56f7838e8926d6256b46e359
1 /* Input parser for Bison
3 Copyright (C) 2000-2003, 2005-2007, 2009-2015, 2018-2021 Free
4 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 <https://www.gnu.org/licenses/>. */
21 #ifndef READER_H_
22 # define READER_H_
24 # include "location.h"
25 # include "symlist.h"
26 # include "named-ref.h"
28 # include "parse-gram.h"
30 typedef struct merger_list
32 struct merger_list* next;
33 uniqstr name;
34 /* One symbol whose type is the one used by all the symbols on which
35 this merging function is used. */
36 symbol *sym;
37 /* Where SYM was bound to this merging function. */
38 location type_declaration_loc;
39 } merger_list;
41 void free_merger_functions (void);
42 extern merger_list *merge_functions;
44 /* List of the start symbols. */
45 extern symbol_list *start_symbols;
47 /* Fetch (or create) a token "YY_PARSE_foo" for start symbol "foo".
49 We don't use the simple "YY_FOO" because (i) we might get clashes
50 with some of our symbols (e.g., cast => YY_CAST), and (ii) upcasing
51 introduces possible clashes between terminal FOO and nonterminal
52 foo. */
53 symbol *switching_token (const symbol *start);
55 void grammar_start_symbols_add (symbol_list *syms);
57 void grammar_current_rule_begin (symbol *lhs, location loc,
58 named_ref *lhs_named_ref);
59 void grammar_current_rule_end (location loc);
60 void grammar_midrule_action (void);
61 /* Apply %empty to the current rule. */
62 void grammar_current_rule_empty_set (location loc);
63 void grammar_current_rule_prec_set (symbol *precsym, location loc);
64 void grammar_current_rule_dprec_set (int dprec, location loc);
65 void grammar_current_rule_merge_set (uniqstr name, location loc);
66 void grammar_current_rule_expect_sr (int count, location loc);
67 void grammar_current_rule_expect_rr (int count, location loc);
68 void grammar_current_rule_symbol_append (symbol *sym, location loc,
69 named_ref *nref);
70 /* Attach an ACTION to the current rule. */
71 void grammar_current_rule_action_append (const char *action, location loc,
72 named_ref *nref, uniqstr tag);
73 /* Attach a PREDICATE to the current rule. */
74 void grammar_current_rule_predicate_append (const char *predicate, location loc);
76 /* Read in the grammar specification. */
77 void reader (const char *gram);
79 /* Was %union seen? */
80 extern bool union_seen;
82 /* Should rules have a default precedence? */
83 extern bool default_prec;
85 #endif /* !READER_H_ */