/* Bison Grammar Scanner -*- C -*-
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA
*/
%option debug nodefault nounput noyywrap never-interactive
%option prefix="gram_" outfile="lex.yy.c"
%{
+/* Work around a bug in flex 2.5.31. See Debian bug 333231
+ <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */
+#undef gram_wrap
+#define gram_wrap() 1
+
#include "system.h"
#include <mbswidth.h>
#include "files.h"
#include "getargs.h"
#include "gram.h"
+#include "quotearg.h"
#include "reader.h"
#include "uniqstr.h"
} \
while (0)
+/* Pacify "gcc -Wmissing-prototypes" when flex 2.5.31 is used. */
+int gram_get_lineno (void);
+FILE *gram_get_in (void);
+FILE *gram_get_out (void);
+int gram_get_leng (void);
+char *gram_get_text (void);
+void gram_set_lineno (int);
+void gram_set_in (FILE *);
+void gram_set_out (FILE *);
+int gram_get_debug (void);
+void gram_set_debug (int);
+int gram_lex_destroy (void);
+
/* Location of scanner cursor. */
boundary scanner_cursor;
"%prec" rule_length--; return PERCENT_PREC;
"%printer" token_type = PERCENT_PRINTER; BEGIN SC_PRE_CODE;
"%pure"[-_]"parser" return PERCENT_PURE_PARSER;
+ "%require" return PERCENT_REQUIRE;
"%right" return PERCENT_RIGHT;
"%skeleton" return PERCENT_SKELETON;
"%start" return PERCENT_START;
"'" STRING_GROW; token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
/* Strings. */
- "\"" STRING_GROW; token_start = loc->start; BEGIN SC_ESCAPED_STRING;
+ "\"" token_start = loc->start; BEGIN SC_ESCAPED_STRING;
/* Prologue. */
"%{" code_start = loc->start; BEGIN SC_PROLOGUE;
<SC_ESCAPED_STRING>
{
"\"" {
- STRING_GROW;
STRING_FINISH;
loc->start = token_start;
val->chars = last_string;
STRING_GROW;
STRING_FINISH;
loc->start = token_start;
- val->symbol = symbol_get (last_string, *loc);
+ val->symbol = symbol_get (quotearg_style (escape_quoting_style,
+ last_string),
+ *loc);
symbol_class_set (val->symbol, token_sym, *loc);
last_string_1 = last_string[1];
symbol_user_token_number_set (val->symbol, last_string_1, *loc);
unsigned long int c = strtoul (yytext + 1, 0, 8);
if (UCHAR_MAX < c)
complain_at (*loc, _("invalid escape sequence: %s"), quote (yytext));
- else if (! c)
+ else if (! c)
complain_at (*loc, _("invalid null character: %s"), quote (yytext));
else
obstack_1grow (&obstack_for_string, c);
}
else
{
- complain_at (*loc, _("missing `{' in `%s'"),
+ complain_at (*loc, _("missing `{' in %s"),
token_name (token_type));
obstack_sgrow (&obstack_for_string, "{}");
STRING_FINISH;
"$"("<"{tag}">")?(-?[0-9]+|"$") handle_dollar (token_type, yytext, *loc);
"@"(-?[0-9]+|"$") handle_at (token_type, yytext, *loc);
+ "$" {
+ warn_at (*loc, _("stray `$'"));
+ obstack_sgrow (&obstack_for_string, "$][");
+ }
+ "@" {
+ warn_at (*loc, _("stray `@'"));
+ obstack_sgrow (&obstack_for_string, "@@");
+ }
+
<<EOF>> unexpected_eof (code_start, "}"); BEGIN INITIAL;
}
if (!type_name)
type_name = "";
obstack_fgrow3 (&obstack_for_string,
- "]b4_rhs_value([%d], [%d], [%s])[",
+ "]b4_rhs_value(%d, %d, [%s])[",
rule_length, n, type_name);
}
else
if (INT_MIN <= num && num <= rule_length && ! get_errno ())
{
int n = num;
- obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location([%d], [%d])[",
+ obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
rule_length, n);
}
else