mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
reader: let symtab deal with the symbols
* src/reader.c (reader): Move the setting up of the builtin symbols to... * src/symtab.c (symbols_new): here.
This commit is contained in:
22
src/reader.c
22
src/reader.c
@@ -700,7 +700,8 @@ packgram (void)
|
||||
if (trace_flag & trace_sets)
|
||||
ritem_print (stderr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*------------------------------------------------------------------.
|
||||
| Read in the grammar specification and record it in the format |
|
||||
| described in gram.h. All actions are copied into ACTION_OBSTACK, |
|
||||
@@ -711,25 +712,10 @@ packgram (void)
|
||||
void
|
||||
reader (void)
|
||||
{
|
||||
/* Initialize the symbol table. */
|
||||
/* Set up symbol_table, semantic_type_table, and the built-in
|
||||
symbols. */
|
||||
symbols_new ();
|
||||
|
||||
/* Construct the accept symbol. */
|
||||
accept = symbol_get ("$accept", empty_loc);
|
||||
accept->content->class = nterm_sym;
|
||||
accept->content->number = nvars++;
|
||||
|
||||
/* Construct the error token */
|
||||
errtoken = symbol_get ("error", empty_loc);
|
||||
errtoken->content->class = token_sym;
|
||||
errtoken->content->number = ntokens++;
|
||||
|
||||
/* Construct a token that represents all undefined literal tokens.
|
||||
It is always token number 2. */
|
||||
undeftoken = symbol_get ("$undefined", empty_loc);
|
||||
undeftoken->content->class = token_sym;
|
||||
undeftoken->content->number = ntokens++;
|
||||
|
||||
gram_in = xfopen (grammar_file, "r");
|
||||
|
||||
gram__flex_debug = trace_flag & trace_scan;
|
||||
|
||||
17
src/symtab.c
17
src/symtab.c
@@ -805,6 +805,23 @@ symbols_new (void)
|
||||
hash_symbol_hasher,
|
||||
hash_symbol_comparator,
|
||||
symbol_free);
|
||||
|
||||
/* Construct the accept symbol. */
|
||||
accept = symbol_get ("$accept", empty_loc);
|
||||
accept->content->class = nterm_sym;
|
||||
accept->content->number = nvars++;
|
||||
|
||||
/* Construct the error token */
|
||||
errtoken = symbol_get ("error", empty_loc);
|
||||
errtoken->content->class = token_sym;
|
||||
errtoken->content->number = ntokens++;
|
||||
|
||||
/* Construct a token that represents all undefined literal tokens.
|
||||
It is always token number 2. */
|
||||
undeftoken = symbol_get ("$undefined", empty_loc);
|
||||
undeftoken->content->class = token_sym;
|
||||
undeftoken->content->number = ntokens++;
|
||||
|
||||
semantic_type_table = hash_xinitialize (HT_INITIAL_CAPACITY,
|
||||
NULL,
|
||||
hash_semantic_type_hasher,
|
||||
|
||||
@@ -345,7 +345,8 @@ void semantic_type_code_props_set (semantic_type *type,
|
||||
| Symbol and semantic type tables. |
|
||||
`----------------------------------*/
|
||||
|
||||
/** Create the symbol and semantic type tables. */
|
||||
/** Create the symbol and semantic type tables, and the built-in
|
||||
symbols. */
|
||||
void symbols_new (void);
|
||||
|
||||
/** Free all the memory allocated for symbols and semantic types. */
|
||||
|
||||
Reference in New Issue
Block a user