* src/symtab.h, src/symtab.c (dummy_symbol_get): this.
(getsym): Rename as...
(symbol_get): this.
+2002-06-30 Akim Demaille <akim@epita.fr>
+
+ * src/reader.c (gensym): Rename as...
+ * src/symtab.h, src/symtab.c (dummy_symbol_get): this.
+ (getsym): Rename as...
+ (symbol_get): this.
+
+
2002-06-30 Akim Demaille <akim@epita.fr>
* src/state.h (state_number_t, STATE_NUMBER_MAX): New.
char *string;
associativity assoc;
} yystype;
-/* Line 272 of /home/lrde/prof/akim/src/bison/data/yacc.c. */
+/* Line 272 of /usr/local/share/bison/yacc.c. */
#line 241 "parse-gram.c"
# define YYSTYPE yystype
# define YYSTYPE_IS_TRIVIAL 1
/* Copy the second part of user declarations. */
-/* Line 292 of /home/lrde/prof/akim/src/bison/data/yacc.c. */
+/* Line 292 of /usr/local/share/bison/yacc.c. */
#line 262 "parse-gram.c"
#if ! defined (yyoverflow) || YYERROR_VERBOSE
case 67:
#line 371 "parse-gram.y"
- { yyval.symbol = getsym (yyvsp[0].string, yylsp[0]); }
+ { yyval.symbol = symbol_get (yyvsp[0].string, yylsp[0]); }
break;
case 68:
case 69:
#line 382 "parse-gram.y"
{
- yyval.symbol = getsym (yyvsp[0].string, yylsp[0]);
+ yyval.symbol = symbol_get (yyvsp[0].string, yylsp[0]);
symbol_class_set (yyval.symbol, token_sym, yylsp[0]);
}
break;
}
-/* Line 1040 of /home/lrde/prof/akim/src/bison/data/yacc.c. */
+/* Line 1040 of /usr/local/share/bison/yacc.c. */
#line 1525 "parse-gram.c"
\f
yyvsp -= yylen;
char *string;
associativity assoc;
} yystype;
-/* Line 1353 of /home/lrde/prof/akim/src/bison/data/yacc.c. */
+/* Line 1353 of /usr/local/share/bison/yacc.c. */
#line 116 "y.tab.h"
# define YYSTYPE yystype
#endif
symbol:
ID { $$ = $1; }
| string_as_id { $$ = $1; }
-| CHARACTER { $$ = getsym ($1, @1); }
+| CHARACTER { $$ = symbol_get ($1, @1); }
;
action:
string_as_id:
STRING
{
- $$ = getsym ($1, @1);
+ $$ = symbol_get ($1, @1);
symbol_class_set ($$, token_sym, @1);
}
;
type = "";
head.next = merge_functions;
- for (syms = &head, n = 1; syms->next != NULL; syms = syms->next, n += 1)
+ for (syms = &head, n = 1; syms->next != NULL; syms = syms->next, n += 1)
if (strcmp (name, syms->next->name) == 0)
break;
if (syms->next == NULL) {
syms->next->next = NULL;
merge_functions = head.next;
} else if (strcmp (type, syms->next->type) != 0)
- warn (_("result type clash on merge function %s: `%s' vs. `%s'"),
+ warn (_("result type clash on merge function %s: `%s' vs. `%s'"),
name, type, syms->next->type);
return n;
}
}
}
-/*-------------------------------------------------------------------.
-| Generate a dummy symbol, a nonterminal, whose name cannot conflict |
-| with the user's names. |
-`-------------------------------------------------------------------*/
-
-static symbol_t *
-gensym (location_t location)
-{
- /* Incremented for each generated symbol */
- static int gensym_count = 0;
- static char buf[256];
-
- symbol_t *sym;
-
- sprintf (buf, "@%d", ++gensym_count);
- sym = getsym (buf, location);
- sym->class = nterm_sym;
- sym->number = nvars++;
- return sym;
-}
\f
/*-------------------------------------------------------------------.
| Parse the input grammar into a one symbol_list_t structure. Each |
/* Make a DUMMY nonterminal, whose location is that of the midrule
action. Create the MIDRULE. */
location_t dummy_location = current_rule->action_location;
- symbol_t *dummy = gensym (dummy_location);
+ symbol_t *dummy = dummy_symbol_get (dummy_location);
symbol_list_t *midrule = symbol_list_new (dummy, dummy_location);
/* Make a new rule, whose body is empty, before the current one, so
warn_at (location, _("%%dprec affects only GLR parsers"));
if (dprec <= 0)
complain_at (location, _("%%dprec must be followed by positive number"));
- else if (current_rule->dprec != 0)
+ else if (current_rule->dprec != 0)
complain_at (location, _("only one %%dprec allowed per rule"));
current_rule->dprec = dprec;
}
{
if (! glr_parser)
warn_at (location, _("%%merge affects only GLR parsers"));
- if (current_rule->merger != 0)
+ if (current_rule->merger != 0)
complain_at (location, _("only one %%merge allowed per rule"));
- current_rule->merger =
+ current_rule->merger =
get_merge_function (name, current_rule->sym->type_name);
}
symbols_new ();
/* Construct the axiom symbol. */
- axiom = getsym ("$axiom", empty_location);
+ axiom = symbol_get ("$axiom", empty_location);
axiom->class = nterm_sym;
axiom->number = nvars++;
/* Construct the error token */
- errtoken = getsym ("error", empty_location);
+ errtoken = symbol_get ("error", empty_location);
errtoken->class = token_sym;
errtoken->number = ntokens++;
/* Construct a token that represents all undefined literal tokens.
It is always token number 2. */
- undeftoken = getsym ("$undefined.", empty_location);
+ undeftoken = symbol_get ("$undefined.", empty_location);
undeftoken->class = token_sym;
undeftoken->number = ntokens++;
/* If the user did not define her EOFTOKEN, do it now. */
if (!eoftoken)
{
- eoftoken = getsym ("$", empty_location);
+ eoftoken = symbol_get ("$", empty_location);
eoftoken->class = token_sym;
eoftoken->number = 0;
/* Value specified by POSIX. */
#define yyrestart gram_restart
#define yytext gram_text
-#line 19 "scan-gram.c"
+#line 19 "lex.yy.c"
/* A lexical scanner generated by flex */
/* Scanner skeleton version:
#define YY_FLEX_MINOR_VERSION 5
#include <stdio.h>
-
+#include <errno.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
#ifdef __cplusplus
#include <stdlib.h>
+#ifndef _WIN32
#include <unistd.h>
+#endif
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
#define SC_PROLOGUE 7
#define SC_EPILOGUE 8
-#line 827 "scan-gram.c"
+#line 829 "lex.yy.c"
/* Macros after this point can all be overridden by user definitions in
* section 1.
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
- else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
- && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(yyin); \
+ } \
+ }
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
/*----------------------------.
| Scanning Bison directives. |
`----------------------------*/
-#line 1001 "scan-gram.c"
+#line 1014 "lex.yy.c"
if ( yy_init )
{
YY_RULE_SETUP
#line 162 "scan-gram.l"
{
- yylval->symbol = getsym (yytext, *yylloc);
+ yylval->symbol = symbol_get (yytext, *yylloc);
return ID;
}
YY_BREAK
assert (yy_top_state () == INITIAL);
{
YY_OBS_FINISH;
- yylval->symbol = getsym (last_string, *yylloc);
+ yylval->symbol = symbol_get (last_string, *yylloc);
symbol_class_set (yylval->symbol, token_sym, *yylloc);
symbol_user_token_number_set (yylval->symbol, last_string[1], *yylloc);
YY_OBS_FREE;
#line 528 "scan-gram.l"
YY_FATAL_ERROR( "flex scanner jammed" );
YY_BREAK
-#line 1861 "scan-gram.c"
+#line 1874 "lex.yy.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
}
+#ifndef _WIN32
+#include <unistd.h>
+#else
#ifndef YY_ALWAYS_INTERACTIVE
#ifndef YY_NEVER_INTERACTIVE
extern int isatty YY_PROTO(( int ));
#endif
#endif
+#endif
#ifdef YY_USE_PROTOS
void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
{eols} YY_LINES; YY_STEP;
{blanks} YY_STEP;
{id} {
- yylval->symbol = getsym (yytext, *yylloc);
+ yylval->symbol = symbol_get (yytext, *yylloc);
return ID;
}
assert (yy_top_state () == INITIAL);
{
YY_OBS_FINISH;
- yylval->symbol = getsym (last_string, *yylloc);
+ yylval->symbol = symbol_get (last_string, *yylloc);
symbol_class_set (yylval->symbol, token_sym, *yylloc);
symbol_user_token_number_set (yylval->symbol, last_string[1], *yylloc);
YY_OBS_FREE;
`----------------------------------------------------------------*/
symbol_t *
-getsym (const char *key, location_t location)
+symbol_get (const char *key, location_t location)
{
symbol_t probe;
symbol_t *entry;
}
+/*------------------------------------------------------------------.
+| Generate a dummy nonterminal, whose name cannot conflict with the |
+| user's names. |
+`------------------------------------------------------------------*/
+
+symbol_t *
+dummy_symbol_get (location_t location)
+{
+ /* Incremented for each generated symbol. */
+ static int dummy_count = 0;
+ static char buf[256];
+
+ symbol_t *sym;
+
+ sprintf (buf, "@%d", ++dummy_count);
+ sym = symbol_get (buf, location);
+ sym->class = nterm_sym;
+ sym->number = nvars++;
+ return sym;
+}
+
+
/*-------------------.
| Free the symbols. |
`-------------------*/
void symbol_tag_print PARAMS ((symbol_t *symbol, FILE *out));
/* Fetch (or create) the symbol associated to KEY. */
-symbol_t *getsym PARAMS ((const char *key, location_t location));
+symbol_t *symbol_get PARAMS ((const char *key, location_t location));
+
+/* Generate a dummy nonterminal, whose name cannot conflict with the
+ user's names. */
+symbol_t *dummy_symbol_get PARAMS ((location_t location));
/* Declare the new SYMBOL. Make it an alias of SYMVAL. */
void symbol_make_alias PARAMS ((symbol_t *symbol, symbol_t *symval));