[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scanner robustness
From: |
Akim Demaille |
Subject: |
Re: Scanner robustness |
Date: |
12 Jun 2002 14:50:23 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter) |
>>>>> "Akim" == Akim Demaille <address@hidden> writes:
Akim> I have also discovered $-n is not supported properly. To be
Akim> checked + fixed.
I forgot to send the patch :)
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/scan-gram.l (SC_PROLOGUE): Don't eat characters amongst
['"/] too eagerly.
* tests/input.at (Torturing the Scanner): New.
Index: src/scan-gram.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-gram.l,v
retrieving revision 1.4
diff -u -u -r1.4 scan-gram.l
--- src/scan-gram.l 11 Jun 2002 21:46:16 -0000 1.4
+++ src/scan-gram.l 12 Jun 2002 12:47:48 -0000
@@ -440,7 +440,7 @@
"$"("<".*">")?(-?[0-9]+|"$") { handle_dollar (yytext); }
"@"(-?[0-9]+|"$") { handle_at (yytext); }
- [^\[\]$/\'\"@\{\}\n\r]+ YY_OBS_GROW;
+ address@hidden/\'\"\{\}\n\r]+ YY_OBS_GROW;
{eols} YY_OBS_GROW; YY_LINES;
/* A lose $, or /, or etc. */
@@ -471,7 +471,7 @@
return PROLOGUE;
}
- [^\[\]%\n\r]+ YY_OBS_GROW;
+ [^%\[\]/\'\"\n\r]+ YY_OBS_GROW;
"%"+[^%\}\n\r]+ YY_OBS_GROW;
{eols} YY_OBS_GROW; YY_LINES;
Index: tests/input.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/input.at,v
retrieving revision 1.5
diff -u -u -r1.5 input.at
--- tests/input.at 11 Jun 2002 08:08:22 -0000 1.5
+++ tests/input.at 12 Jun 2002 12:47:48 -0000
@@ -1,5 +1,5 @@
# Checking the output filenames. -*- Autotest -*-
-# Copyright 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -19,6 +19,31 @@
AT_BANNER([[Input Processing.]])
# Mostly test that we are robust to mistakes.
+
+
+## ----------------------- ##
+## Torturing the Scanner. ##
+## ----------------------- ##
+
+AT_SETUP([Torturing the Scanner])
+
+AT_DATA([input.y],
+[[%{
+/* This is seen in GCC: a %{ and %} in middle of a comment. */
+const char *foo = "So %{ and %} can be here.";
+%}
+/* %{ and %} can be here too. */
+
+%%
+exp: 'a';
+]])
+
+AT_CHECK([bison input.y])
+
+AT_CLEANUP
+
+
+
## ------------ ##
## Invalid $n. ##