mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-20 01:33:03 +00:00
* src/gram.h (associativity): New enum type which replaces the
former CPP macros `RIGHT_ASSOC', `LEFT_ASSOC' and `NON_ASSOC' with `right_assoc', `left_assoc' and `non_assoc'. Adjust all dependencies. * src/reader.c: Formatting changes. (LTYPESTR): Don't define it, use it as a literal in `reader_output_yylsp'. * src/symtab.h (symbol_class): New enum type which replaces the former CPP macros `SUNKNOWN', `STOKEN and `SNTERM' with `sunknown', `stoken and `snterm'.
This commit is contained in:
13
ChangeLog
13
ChangeLog
@@ -1,3 +1,16 @@
|
|||||||
|
2000-10-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* src/gram.h (associativity): New enum type which replaces the
|
||||||
|
former CPP macros `RIGHT_ASSOC', `LEFT_ASSOC' and `NON_ASSOC' with
|
||||||
|
`right_assoc', `left_assoc' and `non_assoc'.
|
||||||
|
Adjust all dependencies.
|
||||||
|
* src/reader.c: Formatting changes.
|
||||||
|
(LTYPESTR): Don't define it, use it as a literal in
|
||||||
|
`reader_output_yylsp'.
|
||||||
|
* src/symtab.h (symbol_class): New enum type which replaces the
|
||||||
|
former CPP macros `SUNKNOWN', `STOKEN and `SNTERM' with
|
||||||
|
`sunknown', `stoken and `snterm'.
|
||||||
|
|
||||||
2000-10-02 Akim Demaille <akim@epita.fr>
|
2000-10-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/getargs.c (fixed_outfiles): Rename as...
|
* src/getargs.c (fixed_outfiles): Rename as...
|
||||||
|
|||||||
@@ -131,29 +131,29 @@ resolve_sr_conflict (int state, int lookaheadnum)
|
|||||||
|
|
||||||
switch (sassoc[i])
|
switch (sassoc[i])
|
||||||
{
|
{
|
||||||
case RIGHT_ASSOC:
|
case right_assoc:
|
||||||
log_resolution (state, lookaheadnum, i, _("shift"));
|
log_resolution (state, lookaheadnum, i, _("shift"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LEFT_ASSOC:
|
case left_assoc:
|
||||||
log_resolution (state, lookaheadnum, i, _("reduce"));
|
log_resolution (state, lookaheadnum, i, _("reduce"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NON_ASSOC:
|
case non_assoc:
|
||||||
log_resolution (state, lookaheadnum, i, _("an error"));
|
log_resolution (state, lookaheadnum, i, _("an error"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sassoc[i] != RIGHT_ASSOC)
|
if (sassoc[i] != right_assoc)
|
||||||
{
|
{
|
||||||
*fp2 &= ~mask; /* flush the shift for this token */
|
*fp2 &= ~mask; /* flush the shift for this token */
|
||||||
flush_shift (state, i);
|
flush_shift (state, i);
|
||||||
}
|
}
|
||||||
if (sassoc[i] != LEFT_ASSOC)
|
if (sassoc[i] != left_assoc)
|
||||||
{
|
{
|
||||||
*fp1 &= ~mask; /* flush the reduce for this token */
|
*fp1 &= ~mask; /* flush the reduce for this token */
|
||||||
}
|
}
|
||||||
if (sassoc[i] == NON_ASSOC)
|
if (sassoc[i] == non_assoc)
|
||||||
{
|
{
|
||||||
/* Record an explicit error for this token. */
|
/* Record an explicit error for this token. */
|
||||||
*errtokens++ = i;
|
*errtokens++ = i;
|
||||||
|
|||||||
@@ -97,10 +97,13 @@ extern int start_symbol;
|
|||||||
|
|
||||||
|
|
||||||
/* associativity values in elements of rassoc, sassoc. */
|
/* associativity values in elements of rassoc, sassoc. */
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
right_assoc,
|
||||||
|
left_assoc,
|
||||||
|
non_assoc
|
||||||
|
} associativity;
|
||||||
|
|
||||||
#define RIGHT_ASSOC 1
|
|
||||||
#define LEFT_ASSOC 2
|
|
||||||
#define NON_ASSOC 3
|
|
||||||
|
|
||||||
/* token translation table: indexed by a token number as returned by
|
/* token translation table: indexed by a token number as returned by
|
||||||
the user's yylex routine, it yields the internal token number used
|
the user's yylex routine, it yields the internal token number used
|
||||||
|
|||||||
@@ -418,7 +418,7 @@ lex (void)
|
|||||||
*p++ = '\'';
|
*p++ = '\'';
|
||||||
*p = 0;
|
*p = 0;
|
||||||
symval = getsym (token_buffer);
|
symval = getsym (token_buffer);
|
||||||
symval->class = STOKEN;
|
symval->class = token_sym;
|
||||||
if (!symval->user_token_number)
|
if (!symval->user_token_number)
|
||||||
symval->user_token_number = code;
|
symval->user_token_number = code;
|
||||||
return IDENTIFIER;
|
return IDENTIFIER;
|
||||||
@@ -440,7 +440,7 @@ lex (void)
|
|||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
||||||
symval = getsym (token_buffer);
|
symval = getsym (token_buffer);
|
||||||
symval->class = STOKEN;
|
symval->class = token_sym;
|
||||||
|
|
||||||
return IDENTIFIER;
|
return IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
|||||||
152
src/reader.c
152
src/reader.c
@@ -34,28 +34,6 @@
|
|||||||
|
|
||||||
extern char *printable_version PARAMS ((int));
|
extern char *printable_version PARAMS ((int));
|
||||||
|
|
||||||
#define LTYPESTR "\
|
|
||||||
\n\
|
|
||||||
#ifndef YYLTYPE\n\
|
|
||||||
typedef\n\
|
|
||||||
struct yyltype\n\
|
|
||||||
\
|
|
||||||
{\n\
|
|
||||||
int timestamp;\n\
|
|
||||||
int first_line;\n\
|
|
||||||
int first_column;\
|
|
||||||
\n\
|
|
||||||
int last_line;\n\
|
|
||||||
int last_column;\n\
|
|
||||||
char *text;\n\
|
|
||||||
}\n\
|
|
||||||
\
|
|
||||||
yyltype;\n\
|
|
||||||
\n\
|
|
||||||
#define YYLTYPE yyltype\n\
|
|
||||||
#endif\n\
|
|
||||||
\n"
|
|
||||||
|
|
||||||
/* Number of slots allocated (but not necessarily used yet) in `rline' */
|
/* Number of slots allocated (but not necessarily used yet) in `rline' */
|
||||||
static int rline_allocated;
|
static int rline_allocated;
|
||||||
|
|
||||||
@@ -78,11 +56,14 @@ static bucket *startval;
|
|||||||
they must be unions. */
|
they must be unions. */
|
||||||
static int value_components_used;
|
static int value_components_used;
|
||||||
|
|
||||||
static int typed; /* nonzero if %union has been seen. */
|
/* Nonzero if %union has been seen. */
|
||||||
|
static int typed;
|
||||||
|
|
||||||
static int lastprec; /* incremented for each %left, %right or %nonassoc seen */
|
/* Incremented for each %left, %right or %nonassoc seen */
|
||||||
|
static int lastprec;
|
||||||
|
|
||||||
static int gensym_count; /* incremented for each generated symbol */
|
/* Incremented for each generated symbol */
|
||||||
|
static int gensym_count;
|
||||||
|
|
||||||
static bucket *errtoken;
|
static bucket *errtoken;
|
||||||
static bucket *undeftoken;
|
static bucket *undeftoken;
|
||||||
@@ -358,14 +339,14 @@ copy_definition (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------------.
|
/*-------------------------------------------------------------------.
|
||||||
| Parse what comes after %token or %nterm. For %token, what_is is |
|
| Parse what comes after %token or %nterm. For %token, WHAT_IS is |
|
||||||
| STOKEN and what_is_not is SNTERM. For %nterm, the arguments are |
|
| token_sym and WHAT_IS_NOT is nterm_sym. For %nterm, the arguments |
|
||||||
| reversed. |
|
| are reversed. |
|
||||||
`-----------------------------------------------------------------*/
|
`-------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_token_decl (int what_is, int what_is_not)
|
parse_token_decl (symbol_class what_is, symbol_class what_is_not)
|
||||||
{
|
{
|
||||||
int token = 0;
|
int token = 0;
|
||||||
char *typename = 0;
|
char *typename = 0;
|
||||||
@@ -398,7 +379,7 @@ parse_token_decl (int what_is, int what_is_not)
|
|||||||
else if (token == IDENTIFIER && *symval->tag == '\"' && symbol)
|
else if (token == IDENTIFIER && *symval->tag == '\"' && symbol)
|
||||||
{
|
{
|
||||||
translations = 1;
|
translations = 1;
|
||||||
symval->class = STOKEN;
|
symval->class = token_sym;
|
||||||
symval->type_name = typename;
|
symval->type_name = typename;
|
||||||
symval->user_token_number = symbol->user_token_number;
|
symval->user_token_number = symbol->user_token_number;
|
||||||
symbol->user_token_number = SALIAS;
|
symbol->user_token_number = SALIAS;
|
||||||
@@ -417,7 +398,7 @@ parse_token_decl (int what_is, int what_is_not)
|
|||||||
if (symbol->class == what_is_not)
|
if (symbol->class == what_is_not)
|
||||||
complain (_("symbol %s redefined"), symbol->tag);
|
complain (_("symbol %s redefined"), symbol->tag);
|
||||||
symbol->class = what_is;
|
symbol->class = what_is;
|
||||||
if (what_is == SNTERM && oldclass != SNTERM)
|
if (what_is == nterm_sym && oldclass != nterm_sym)
|
||||||
symbol->value = nvars++;
|
symbol->value = nvars++;
|
||||||
|
|
||||||
if (typename)
|
if (typename)
|
||||||
@@ -436,7 +417,7 @@ parse_token_decl (int what_is, int what_is_not)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
complain (_("`%s' is invalid in %s"),
|
complain (_("`%s' is invalid in %s"),
|
||||||
token_buffer, (what_is == STOKEN) ? "%token" : "%nterm");
|
token_buffer, (what_is == token_sym) ? "%token" : "%nterm");
|
||||||
skip_to_char ('%');
|
skip_to_char ('%');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -444,7 +425,9 @@ parse_token_decl (int what_is, int what_is_not)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Parse what comes after %start */
|
/*------------------------------.
|
||||||
|
| Parse what comes after %start |
|
||||||
|
`------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_start_decl (void)
|
parse_start_decl (void)
|
||||||
@@ -556,11 +539,13 @@ parse_type_decl (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* read in a %left, %right or %nonassoc declaration and record its information. */
|
/*----------------------------------------------------------------.
|
||||||
/* assoc is either LEFT_ASSOC, RIGHT_ASSOC or NON_ASSOC. */
|
| Read in a %left, %right or %nonassoc declaration and record its |
|
||||||
|
| information. |
|
||||||
|
`----------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_assoc_decl (int assoc)
|
parse_assoc_decl (associativity assoc)
|
||||||
{
|
{
|
||||||
int k;
|
int k;
|
||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
@@ -597,9 +582,9 @@ parse_assoc_decl (int assoc)
|
|||||||
complain (_("redefining precedence of %s"), symval->tag);
|
complain (_("redefining precedence of %s"), symval->tag);
|
||||||
symval->prec = lastprec;
|
symval->prec = lastprec;
|
||||||
symval->assoc = assoc;
|
symval->assoc = assoc;
|
||||||
if (symval->class == SNTERM)
|
if (symval->class == nterm_sym)
|
||||||
complain (_("symbol %s redefined"), symval->tag);
|
complain (_("symbol %s redefined"), symval->tag);
|
||||||
symval->class = STOKEN;
|
symval->class = token_sym;
|
||||||
if (name)
|
if (name)
|
||||||
{ /* record the type, if one is specified */
|
{ /* record the type, if one is specified */
|
||||||
if (symval->type_name == NULL)
|
if (symval->type_name == NULL)
|
||||||
@@ -639,9 +624,11 @@ token_buffer);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* copy the union declaration into fattrs (and fdefines),
|
/*-------------------------------------------------------------------.
|
||||||
where it is made into the
|
| Copy the union declaration into fattrs (and fdefines), where it is |
|
||||||
definition of YYSTYPE, the type of elements of the parser value stack. */
|
| made into the definition of YYSTYPE, the type of elements of the |
|
||||||
|
| parser value stack. |
|
||||||
|
`-------------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_union_decl (void)
|
parse_union_decl (void)
|
||||||
@@ -710,8 +697,11 @@ parse_union_decl (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse the declaration %expect N which says to expect N
|
|
||||||
shift-reduce conflicts. */
|
/*-------------------------------------------------------.
|
||||||
|
| Parse the declaration %expect N which says to expect N |
|
||||||
|
| shift-reduce conflicts. |
|
||||||
|
`-------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
parse_expect_decl (void)
|
parse_expect_decl (void)
|
||||||
@@ -789,7 +779,7 @@ parse_thong_decl (void)
|
|||||||
skip_to_char ('%');
|
skip_to_char ('%');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
symval->class = STOKEN;
|
symval->class = token_sym;
|
||||||
symval->type_name = typename;
|
symval->type_name = typename;
|
||||||
symval->user_token_number = SALIAS;
|
symval->user_token_number = SALIAS;
|
||||||
symbol = symval;
|
symbol = symval;
|
||||||
@@ -812,7 +802,7 @@ parse_thong_decl (void)
|
|||||||
skip_to_char ('%');
|
skip_to_char ('%');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
symval->class = STOKEN;
|
symval->class = token_sym;
|
||||||
symval->type_name = typename;
|
symval->type_name = typename;
|
||||||
symval->user_token_number = usrtoknum;
|
symval->user_token_number = usrtoknum;
|
||||||
|
|
||||||
@@ -822,6 +812,7 @@ parse_thong_decl (void)
|
|||||||
nsyms--; /* symbol and symval combined are only one symbol */
|
nsyms--; /* symbol and symval combined are only one symbol */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------.
|
/*----------------------------------------------------------------.
|
||||||
| Read from finput until `%%' is seen. Discard the `%%'. Handle |
|
| Read from finput until `%%' is seen. Discard the `%%'. Handle |
|
||||||
| any `%' declarations, and copy the contents of any `%{ ... %}' |
|
| any `%' declarations, and copy the contents of any `%{ ... %}' |
|
||||||
@@ -852,11 +843,11 @@ read_declarations (void)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TOKEN:
|
case TOKEN:
|
||||||
parse_token_decl (STOKEN, SNTERM);
|
parse_token_decl (token_sym, nterm_sym);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NTERM:
|
case NTERM:
|
||||||
parse_token_decl (SNTERM, STOKEN);
|
parse_token_decl (nterm_sym, token_sym);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TYPE:
|
case TYPE:
|
||||||
@@ -877,16 +868,17 @@ read_declarations (void)
|
|||||||
case THONG:
|
case THONG:
|
||||||
parse_thong_decl ();
|
parse_thong_decl ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LEFT:
|
case LEFT:
|
||||||
parse_assoc_decl (LEFT_ASSOC);
|
parse_assoc_decl (left_assoc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
parse_assoc_decl (RIGHT_ASSOC);
|
parse_assoc_decl (right_assoc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NONASSOC:
|
case NONASSOC:
|
||||||
parse_assoc_decl (NON_ASSOC);
|
parse_assoc_decl (non_assoc);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SEMANTIC_PARSER:
|
case SEMANTIC_PARSER:
|
||||||
@@ -1234,7 +1226,7 @@ gensym (void)
|
|||||||
|
|
||||||
sprintf (token_buffer, "@%d", ++gensym_count);
|
sprintf (token_buffer, "@%d", ++gensym_count);
|
||||||
sym = getsym (token_buffer);
|
sym = getsym (token_buffer);
|
||||||
sym->class = SNTERM;
|
sym->class = nterm_sym;
|
||||||
sym->value = nvars++;
|
sym->value = nvars++;
|
||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
@@ -1374,13 +1366,13 @@ readgram (void)
|
|||||||
|
|
||||||
/* mark the rule's lhs as a nonterminal if not already so. */
|
/* mark the rule's lhs as a nonterminal if not already so. */
|
||||||
|
|
||||||
if (lhs->class == SUNKNOWN)
|
if (lhs->class == unknown_sym)
|
||||||
{
|
{
|
||||||
lhs->class = SNTERM;
|
lhs->class = nterm_sym;
|
||||||
lhs->value = nvars;
|
lhs->value = nvars;
|
||||||
nvars++;
|
nvars++;
|
||||||
}
|
}
|
||||||
else if (lhs->class == STOKEN)
|
else if (lhs->class == token_sym)
|
||||||
complain (_("rule given for %s, which is a token"), lhs->tag);
|
complain (_("rule given for %s, which is a token"), lhs->tag);
|
||||||
|
|
||||||
/* read the rhs of the rule. */
|
/* read the rhs of the rule. */
|
||||||
@@ -1534,12 +1526,12 @@ readgram (void)
|
|||||||
*/
|
*/
|
||||||
else if (t == TOKEN)
|
else if (t == TOKEN)
|
||||||
{
|
{
|
||||||
parse_token_decl (STOKEN, SNTERM);
|
parse_token_decl (token_sym, nterm_sym);
|
||||||
t = lex ();
|
t = lex ();
|
||||||
}
|
}
|
||||||
else if (t == NTERM)
|
else if (t == NTERM)
|
||||||
{
|
{
|
||||||
parse_token_decl (SNTERM, STOKEN);
|
parse_token_decl (nterm_sym, token_sym);
|
||||||
t = lex ();
|
t = lex ();
|
||||||
}
|
}
|
||||||
else if (t == TYPE)
|
else if (t == TYPE)
|
||||||
@@ -1592,12 +1584,12 @@ readgram (void)
|
|||||||
/* Report any undefined symbols and consider them nonterminals. */
|
/* Report any undefined symbols and consider them nonterminals. */
|
||||||
|
|
||||||
for (bp = firstsymbol; bp; bp = bp->next)
|
for (bp = firstsymbol; bp; bp = bp->next)
|
||||||
if (bp->class == SUNKNOWN)
|
if (bp->class == unknown_sym)
|
||||||
{
|
{
|
||||||
complain (_
|
complain (_
|
||||||
("symbol %s is used, but is not defined as a token and has no rules"),
|
("symbol %s is used, but is not defined as a token and has no rules"),
|
||||||
bp->tag);
|
bp->tag);
|
||||||
bp->class = SNTERM;
|
bp->class = nterm_sym;
|
||||||
bp->value = nvars++;
|
bp->value = nvars++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1684,7 +1676,7 @@ packsymbols (void)
|
|||||||
|
|
||||||
for (bp = firstsymbol; bp; bp = bp->next)
|
for (bp = firstsymbol; bp; bp = bp->next)
|
||||||
{
|
{
|
||||||
if (bp->class == SNTERM)
|
if (bp->class == nterm_sym)
|
||||||
{
|
{
|
||||||
bp->value += ntokens;
|
bp->value += ntokens;
|
||||||
}
|
}
|
||||||
@@ -1724,12 +1716,12 @@ packsymbols (void)
|
|||||||
continue; /* do not do processing below for SALIASs */
|
continue; /* do not do processing below for SALIASs */
|
||||||
|
|
||||||
}
|
}
|
||||||
else /* bp->class == STOKEN */
|
else /* bp->class == token_sym */
|
||||||
{
|
{
|
||||||
bp->value = tokno++;
|
bp->value = tokno++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bp->class == STOKEN)
|
if (bp->class == token_sym)
|
||||||
{
|
{
|
||||||
if (translations && !(bp->user_token_number))
|
if (translations && !(bp->user_token_number))
|
||||||
bp->user_token_number = ++last_user_token_number;
|
bp->user_token_number = ++last_user_token_number;
|
||||||
@@ -1775,9 +1767,9 @@ packsymbols (void)
|
|||||||
if (!noparserflag)
|
if (!noparserflag)
|
||||||
output_token_defines (ftable);
|
output_token_defines (ftable);
|
||||||
|
|
||||||
if (startval->class == SUNKNOWN)
|
if (startval->class == unknown_sym)
|
||||||
fatal (_("the start symbol %s is undefined"), startval->tag);
|
fatal (_("the start symbol %s is undefined"), startval->tag);
|
||||||
else if (startval->class == STOKEN)
|
else if (startval->class == token_sym)
|
||||||
fatal (_("the start symbol %s is a token"), startval->tag);
|
fatal (_("the start symbol %s is a token"), startval->tag);
|
||||||
|
|
||||||
start_symbol = startval->value;
|
start_symbol = startval->value;
|
||||||
@@ -1849,7 +1841,7 @@ packgram (void)
|
|||||||
ritem[itemno++] = p->sym->value;
|
ritem[itemno++] = p->sym->value;
|
||||||
/* A rule gets by default the precedence and associativity
|
/* A rule gets by default the precedence and associativity
|
||||||
of the last token in it. */
|
of the last token in it. */
|
||||||
if (p->sym->class == STOKEN)
|
if (p->sym->class == token_sym)
|
||||||
{
|
{
|
||||||
rprec[ruleno] = p->sym->prec;
|
rprec[ruleno] = p->sym->prec;
|
||||||
rassoc[ruleno] = p->sym->assoc;
|
rassoc[ruleno] = p->sym->assoc;
|
||||||
@@ -1925,12 +1917,12 @@ reader (void)
|
|||||||
tabinit ();
|
tabinit ();
|
||||||
/* Construct the error token */
|
/* Construct the error token */
|
||||||
errtoken = getsym ("error");
|
errtoken = getsym ("error");
|
||||||
errtoken->class = STOKEN;
|
errtoken->class = token_sym;
|
||||||
errtoken->user_token_number = 256; /* Value specified by POSIX. */
|
errtoken->user_token_number = 256; /* Value specified by POSIX. */
|
||||||
/* Construct a token that represents all undefined literal tokens.
|
/* Construct a token that represents all undefined literal tokens.
|
||||||
It is always token number 2. */
|
It is always token number 2. */
|
||||||
undeftoken = getsym ("$undefined.");
|
undeftoken = getsym ("$undefined.");
|
||||||
undeftoken->class = STOKEN;
|
undeftoken->class = token_sym;
|
||||||
undeftoken->user_token_number = 2;
|
undeftoken->user_token_number = 2;
|
||||||
|
|
||||||
/* Read the declaration section. Copy %{ ... %} groups to FTABLE
|
/* Read the declaration section. Copy %{ ... %} groups to FTABLE
|
||||||
@@ -1967,9 +1959,31 @@ reader (void)
|
|||||||
free_symtab ();
|
free_symtab ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
reader_output_yylsp (FILE *f)
|
reader_output_yylsp (FILE *f)
|
||||||
{
|
{
|
||||||
if (yylsp_needed)
|
if (yylsp_needed)
|
||||||
fprintf (f, LTYPESTR);
|
fputs ("\
|
||||||
|
\n\
|
||||||
|
#ifndef YYLTYPE\n\
|
||||||
|
typedef\n\
|
||||||
|
struct yyltype\n\
|
||||||
|
\
|
||||||
|
{\n\
|
||||||
|
int timestamp;\n\
|
||||||
|
int first_line;\n\
|
||||||
|
int first_column;\
|
||||||
|
\n\
|
||||||
|
int last_line;\n\
|
||||||
|
int last_column;\n\
|
||||||
|
char *text;\n\
|
||||||
|
}\n\
|
||||||
|
\
|
||||||
|
yyltype;\n\
|
||||||
|
\n\
|
||||||
|
#define YYLTYPE yyltype\n\
|
||||||
|
#endif\n\
|
||||||
|
\n",
|
||||||
|
f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ getsym (const char *key)
|
|||||||
bp->link = symtab[hashval];
|
bp->link = symtab[hashval];
|
||||||
bp->next = NULL;
|
bp->next = NULL;
|
||||||
bp->tag = copys(key);
|
bp->tag = copys(key);
|
||||||
bp->class = SUNKNOWN;
|
bp->class = unknown_sym;
|
||||||
|
|
||||||
if (firstsymbol == NULL)
|
if (firstsymbol == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
14
src/symtab.h
14
src/symtab.h
@@ -20,14 +20,18 @@
|
|||||||
|
|
||||||
#ifndef SYMTAB_H_
|
#ifndef SYMTAB_H_
|
||||||
# define SYMTAB_H_
|
# define SYMTAB_H_
|
||||||
|
# include "gram.h"
|
||||||
|
|
||||||
#define TABSIZE 1009
|
#define TABSIZE 1009
|
||||||
|
|
||||||
/* symbol classes */
|
/* symbol classes */
|
||||||
|
|
||||||
#define SUNKNOWN 0
|
typedef enum
|
||||||
#define STOKEN 1 /* terminal symbol */
|
{
|
||||||
#define SNTERM 2 /* non-terminal */
|
unknown_sym,
|
||||||
|
token_sym, /* terminal symbol */
|
||||||
|
nterm_sym /* non-terminal */
|
||||||
|
} symbol_class;
|
||||||
|
|
||||||
#define SALIAS -9991 /* for symbol generated with an alias */
|
#define SALIAS -9991 /* for symbol generated with an alias */
|
||||||
|
|
||||||
@@ -39,13 +43,13 @@ typedef struct bucket
|
|||||||
char *type_name;
|
char *type_name;
|
||||||
short value;
|
short value;
|
||||||
short prec;
|
short prec;
|
||||||
short assoc;
|
associativity assoc;
|
||||||
short user_token_number;
|
short user_token_number;
|
||||||
/* special value SALIAS in the identifier half of the
|
/* special value SALIAS in the identifier half of the
|
||||||
identifier-symbol pair for an alias */
|
identifier-symbol pair for an alias */
|
||||||
struct bucket *alias;
|
struct bucket *alias;
|
||||||
/* points to the other in the identifier-symbol pair for an alias */
|
/* points to the other in the identifier-symbol pair for an alias */
|
||||||
char class;
|
symbol_class class;
|
||||||
}
|
}
|
||||||
bucket;
|
bucket;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user