X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/4a678af8c6f178b797e42a60d7ee3774afbdc14e..3b2942e671eadc31ca5cacf4c2965a1cac4edf04:/src/scan-gram.l?ds=sidebyside diff --git a/src/scan-gram.l b/src/scan-gram.l index d5d92c4c..c1a53276 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -24,9 +24,6 @@ %option prefix="gram_" outfile="lex.yy.c" %{ -#include -#include "system.h" - /* Work around a bug in flex 2.5.31. See Debian bug 333231 . */ #undef gram_wrap @@ -37,7 +34,6 @@ #include "complain.h" #include "files.h" -#include "getargs.h" /* yacc_flag */ #include "gram.h" #include "quotearg.h" #include "reader.h" @@ -70,10 +66,6 @@ gram_scanner_last_string_free (void) STRING_FREE; } -/* The location of the most recently saved token, if it was a - BRACED_CODE token; otherwise, this has an unspecified value. */ -location gram_last_braced_code_loc; - static void handle_syncline (char *, location); static unsigned long int scan_integer (char const *p, int base, location loc); static int convert_ucn_to_byte (char const *hex_text); @@ -196,11 +188,13 @@ splice (\\[ \f\t\v]*\n)* "%prec" return PERCENT_PREC; "%printer" return PERCENT_PRINTER; "%pure"[-_]"parser" return PERCENT_PURE_PARSER; + "%push"[-_]"parser" return PERCENT_PUSH_PARSER; "%require" return PERCENT_REQUIRE; "%right" return PERCENT_RIGHT; "%skeleton" return PERCENT_SKELETON; "%start" return PERCENT_START; "%start-header" return PERCENT_START_HEADER; + "%symbol-default" return PERCENT_SYMBOL_DEFAULT; "%term" return PERCENT_TOKEN; "%token" return PERCENT_TOKEN; "%token"[-_]"table" return PERCENT_TOKEN_TABLE; @@ -344,15 +338,23 @@ splice (\\[ \f\t\v]*\n)* { - "\"" { + "\""|"\n" { + if (yytext[0] == '\n') + unexpected_newline (token_start, "\""); + STRING_FINISH; + loc->start = token_start; + val->chars = last_string; + BEGIN INITIAL; + return STRING; + } + <> { + unexpected_eof (token_start, "\""); STRING_FINISH; loc->start = token_start; val->chars = last_string; BEGIN INITIAL; return STRING; } - \n unexpected_newline (token_start, "\""); BEGIN INITIAL; - <> unexpected_eof (token_start, "\""); BEGIN INITIAL; } /*----------------------------------------------------------. @@ -362,7 +364,9 @@ splice (\\[ \f\t\v]*\n)* { - "'" { + "'"|"\n" { + if (yytext[0] == '\n') + unexpected_newline (token_start, "'"); STRING_GROW; STRING_FINISH; loc->start = token_start; @@ -371,8 +375,18 @@ splice (\\[ \f\t\v]*\n)* BEGIN INITIAL; return CHAR; } - \n unexpected_newline (token_start, "'"); BEGIN INITIAL; - <> unexpected_eof (token_start, "'"); BEGIN INITIAL; + <> { + unexpected_eof (token_start, "'"); + STRING_FINISH; + loc->start = token_start; + if (strlen(last_string) > 1) + val->character = last_string[1]; + else + val->character = last_string[0]; + STRING_FREE; + BEGIN INITIAL; + return CHAR; + } } @@ -509,7 +523,6 @@ splice (\\[ \f\t\v]*\n)* STRING_FINISH; loc->start = code_start; val->chars = last_string; - gram_last_braced_code_loc = *loc; BEGIN INITIAL; return BRACED_CODE; } @@ -519,7 +532,14 @@ splice (\\[ \f\t\v]*\n)* (as `<' `<%'). */ "<"{splice}"<" STRING_GROW; - <> unexpected_eof (code_start, "}"); BEGIN INITIAL; + <> { + unexpected_eof (code_start, "}"); + STRING_FINISH; + loc->start = code_start; + val->chars = last_string; + BEGIN INITIAL; + return BRACED_CODE; + } } @@ -537,7 +557,14 @@ splice (\\[ \f\t\v]*\n)* return PROLOGUE; } - <> unexpected_eof (code_start, "%}"); BEGIN INITIAL; + <> { + unexpected_eof (code_start, "%}"); + STRING_FINISH; + loc->start = code_start; + val->chars = last_string; + BEGIN INITIAL; + return PROLOGUE; + } }