summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim@epita.fr>2001-10-02 15:52:24 +0000
committerAkim Demaille <akim@epita.fr>2001-10-02 15:52:24 +0000
commitf1394282f05ddba1e5a69cc4dac98d173ce21219 (patch)
treec02064ce601a5595692cc73a45683fe39eedc450
parentd8b1af2801b4d3c8c0a422e2ce17548a0fa8e819 (diff)
downloadbison-f1394282f05ddba1e5a69cc4dac98d173ce21219.tar.gz
* tests/regression.at (Invalid input): New.
* src/lex.c (lex): Be sure to set `token_buffer' in any case. Reported by Shura.
-rw-r--r--ChangeLog6
-rw-r--r--src/lex.c13
-rw-r--r--tests/regression.at22
3 files changed, 39 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 65895284..47bbaada 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2001-10-02 Akim Demaille <akim@epita.fr>
+ * tests/regression.at (Invalid input): New.
+ * src/lex.c (lex): Be sure to set `token_buffer' in any case.
+ Reported by Shura.
+
+2001-10-02 Akim Demaille <akim@epita.fr>
+
* tests/calc.at: Now that --debug works, the tests must be adjusted.
2001-10-02 Akim Demaille <akim@epita.fr>
diff --git a/src/lex.c b/src/lex.c
index dc1e6be0..d8aa6f89 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -469,32 +469,40 @@ lex (void)
}
case ',':
+ token_buffer = ",";
return tok_comma;
case ':':
+ token_buffer = ":";
return tok_colon;
case ';':
+ token_buffer = ";";
return tok_semicolon;
case '|':
+ token_buffer = "|";
return tok_bar;
case '{':
+ token_buffer = "{";
return tok_left_curly;
case '=':
+ obstack_1grow (&token_obstack, c);
do
{
c = getc (finput);
+ obstack_1grow (&token_obstack, c);
if (c == '\n')
lineno++;
}
while (c == ' ' || c == '\n' || c == '\t');
+ obstack_1grow (&token_obstack, '\0');
+ token_buffer = obstack_finish (&token_obstack);
if (c == '{')
{
- token_buffer = "={";
return tok_left_curly;
}
else
@@ -511,6 +519,9 @@ lex (void)
return parse_percent_token ();
default:
+ obstack_1grow (&token_obstack, c);
+ obstack_1grow (&token_obstack, '\0');
+ token_buffer = obstack_finish (&token_obstack);
return tok_illegal;
}
}
diff --git a/tests/regression.at b/tests/regression.at
index 619a1dcd..9045e226 100644
--- a/tests/regression.at
+++ b/tests/regression.at
@@ -74,7 +74,7 @@ AT_CLEANUP([union.*])
AT_SETUP([%union and C comments])
AT_DATA([union-comment.y],
-[%union
+[%union
{
/* The int. */ int integer;
/* The string. */ char *string ;
@@ -87,3 +87,23 @@ AT_CHECK([bison union-comment.y])
AT_CHECK([fgrep '//*' union-comment.tab.c], [1], [])
AT_CLEANUP([union-comment.*])
+
+
+## --------------- ##
+## invalid input. ##
+## --------------- ##
+
+
+AT_SETUP([Invalid input])
+
+AT_DATA([input.y],
+[[%%
+?
+]])
+
+AT_CHECK([bison input.y], [1], [],
+[input.y:2: invalid input: `?'
+input.y:3: fatal error: no rules in the input grammar
+])
+
+AT_CLEANUP