summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim@epita.fr>2002-06-30 17:27:57 +0000
committerAkim Demaille <akim@epita.fr>2002-06-30 17:27:57 +0000
commit39f4191608f2bbfb5a140b9ff96ecd56f5b287bb (patch)
tree4591830f895c91d96082cf7b8e5a6a46224a9cd4
parentd57650a5ff3d9d1202f6d04de1a10e32cee85499 (diff)
downloadbison-39f4191608f2bbfb5a140b9ff96ecd56f5b287bb.tar.gz
* src/reader.c (gensym): Rename as...
* src/symtab.h, src/symtab.c (dummy_symbol_get): this. (getsym): Rename as... (symbol_get): this.
-rw-r--r--ChangeLog8
-rw-r--r--src/parse-gram.c10
-rw-r--r--src/parse-gram.h2
-rw-r--r--src/parse-gram.y4
-rw-r--r--src/reader.c40
-rw-r--r--src/scan-gram.c37
-rw-r--r--src/scan-gram.l4
-rw-r--r--src/symtab.c24
-rw-r--r--src/symtab.h6
9 files changed, 83 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index becd90f9..a7382db2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
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.
* src/LR0.c, src/LR0.h, src/conflicts.c, src/lalr.c, src/lalr.h,
* src/output.c, src/print.c, src/print_graph.c: Propagate.
diff --git a/src/parse-gram.c b/src/parse-gram.c
index fb695f64..81116268 100644
--- a/src/parse-gram.c
+++ b/src/parse-gram.c
@@ -236,7 +236,7 @@ typedef union {
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
@@ -257,7 +257,7 @@ typedef struct yyltype
/* 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
@@ -1479,7 +1479,7 @@ yyreduce:
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:
@@ -1490,7 +1490,7 @@ yyreduce:
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;
@@ -1520,7 +1520,7 @@ yyreduce:
}
-/* 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"
yyvsp -= yylen;
diff --git a/src/parse-gram.h b/src/parse-gram.h
index 57314fcf..f1abdd84 100644
--- a/src/parse-gram.h
+++ b/src/parse-gram.h
@@ -111,7 +111,7 @@ typedef union {
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
diff --git a/src/parse-gram.y b/src/parse-gram.y
index 2d00e035..df629d8f 100644
--- a/src/parse-gram.y
+++ b/src/parse-gram.y
@@ -368,7 +368,7 @@ rhs:
symbol:
ID { $$ = $1; }
| string_as_id { $$ = $1; }
-| CHARACTER { $$ = getsym ($1, @1); }
+| CHARACTER { $$ = symbol_get ($1, @1); }
;
action:
@@ -380,7 +380,7 @@ action:
string_as_id:
STRING
{
- $$ = getsym ($1, @1);
+ $$ = symbol_get ($1, @1);
symbol_class_set ($$, token_sym, @1);
}
;
diff --git a/src/reader.c b/src/reader.c
index 088875e0..3c1fe2f2 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -126,7 +126,7 @@ get_merge_function (const char* name, const char* type)
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) {
@@ -136,7 +136,7 @@ get_merge_function (const char* name, const char* type)
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;
}
@@ -160,26 +160,6 @@ free_merger_functions (void)
}
}
-/*-------------------------------------------------------------------.
-| 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;
-}
/*-------------------------------------------------------------------.
| Parse the input grammar into a one symbol_list_t structure. Each |
@@ -323,7 +303,7 @@ grammar_midrule_action (void)
/* 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
@@ -371,7 +351,7 @@ grammar_current_rule_dprec_set (int dprec, location_t location)
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;
}
@@ -384,9 +364,9 @@ grammar_current_rule_merge_set (const char* name, location_t location)
{
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);
}
@@ -499,18 +479,18 @@ reader (void)
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++;
@@ -536,7 +516,7 @@ reader (void)
/* 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. */
diff --git a/src/scan-gram.c b/src/scan-gram.c
index cb71d622..859a8105 100644
--- a/src/scan-gram.c
+++ b/src/scan-gram.c
@@ -15,7 +15,7 @@
#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:
@@ -27,7 +27,7 @@
#define YY_FLEX_MINOR_VERSION 5
#include <stdio.h>
-
+#include <errno.h>
/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
#ifdef c_plusplus
@@ -40,7 +40,9 @@
#ifdef __cplusplus
#include <stdlib.h>
+#ifndef _WIN32
#include <unistd.h>
+#endif
/* Use prototypes in function declarations. */
#define YY_USE_PROTOS
@@ -823,7 +825,7 @@ static void handle_at PARAMS ((braced_code_t code_kind,
#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.
@@ -923,9 +925,20 @@ YY_MALLOC_DECL
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();" -
@@ -997,7 +1010,7 @@ YY_DECL
/*----------------------------.
| Scanning Bison directives. |
`----------------------------*/
-#line 1001 "scan-gram.c"
+#line 1014 "lex.yy.c"
if ( yy_init )
{
@@ -1291,7 +1304,7 @@ case 39:
YY_RULE_SETUP
#line 162 "scan-gram.l"
{
- yylval->symbol = getsym (yytext, *yylloc);
+ yylval->symbol = symbol_get (yytext, *yylloc);
return ID;
}
YY_BREAK
@@ -1482,7 +1495,7 @@ YY_RULE_SETUP
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;
@@ -1857,7 +1870,7 @@ YY_RULE_SETUP
#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();
@@ -2421,11 +2434,15 @@ YY_BUFFER_STATE b;
}
+#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 )
diff --git a/src/scan-gram.l b/src/scan-gram.l
index e5147b7f..d71c3f29 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -160,7 +160,7 @@ blanks [ \t\f]+
{eols} YY_LINES; YY_STEP;
{blanks} YY_STEP;
{id} {
- yylval->symbol = getsym (yytext, *yylloc);
+ yylval->symbol = symbol_get (yytext, *yylloc);
return ID;
}
@@ -292,7 +292,7 @@ blanks [ \t\f]+
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;
diff --git a/src/symtab.c b/src/symtab.c
index bb1b275e..7355bdd3 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -447,7 +447,7 @@ symbols_new (void)
`----------------------------------------------------------------*/
symbol_t *
-getsym (const char *key, location_t location)
+symbol_get (const char *key, location_t location)
{
symbol_t probe;
symbol_t *entry;
@@ -465,6 +465,28 @@ getsym (const char *key, location_t location)
}
+/*------------------------------------------------------------------.
+| 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. |
`-------------------*/
diff --git a/src/symtab.h b/src/symtab.h
index 034b1285..8a926eeb 100644
--- a/src/symtab.h
+++ b/src/symtab.h
@@ -103,7 +103,11 @@ const char *symbol_tag_get_n PARAMS ((symbol_t *symbol, int n));
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));