X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/255227393f15ba5b593070f19d99fabbc96499b8..a2bc9dbc7b577c891811dd96f66a8e0daa66bf93:/src/scan-gram.l diff --git a/src/scan-gram.l b/src/scan-gram.l index 502fabaa..a31cd02e 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -1,6 +1,6 @@ /* Bison Grammar Scanner -*- C -*- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -136,14 +136,16 @@ splice (\\[ \f\t\v]*\n)* int token_type IF_LINT (= 0); /* Location of most recent identifier, when applicable. */ - location id_loc IF_LINT (= *loc); + location id_loc IF_LINT (= empty_location); - /* Where containing code started, when applicable. */ - boundary code_start IF_LINT (= loc->start); + /* Where containing code started, when applicable. Its initial + value is relevant only when yylex is invoked in the SC_EPILOGUE + start condition. */ + boundary code_start = scanner_cursor; /* Where containing comment or string or character literal started, when applicable. */ - boundary token_start IF_LINT (= loc->start); + boundary token_start IF_LINT (= scanner_cursor); %} @@ -154,10 +156,15 @@ splice (\\[ \f\t\v]*\n)* { [ \f\n\t\v] ; + "," warn_at (*loc, _("stray `,' treated as white space")); /* Comments. */ - "/*" token_start = loc->start; context_state = YY_START; BEGIN SC_YACC_COMMENT; "//".* ; + "/*" { + token_start = loc->start; + context_state = YY_START; + BEGIN SC_YACC_COMMENT; + } /* #line directives are not documented, and may be withdrawn or modified in future versions of Bison. */ @@ -215,10 +222,6 @@ splice (\\[ \f\t\v]*\n)* "|" rule_length = 0; return PIPE; ";" return SEMICOLON; - "," { - warn_at (*loc, _("stray `,' treated as white space")); - } - {id} { val->symbol = symbol_get (yytext, *loc); id_loc = *loc; @@ -269,10 +272,7 @@ splice (\\[ \f\t\v]*\n)* "%%" { static int percent_percent_count; if (++percent_percent_count == 2) - { - code_start = loc->start; - BEGIN SC_EPILOGUE; - } + BEGIN SC_EPILOGUE; return PERCENT_PERCENT; } @@ -558,7 +558,7 @@ splice (\\[ \f\t\v]*\n)* should also diagnose other Bison extensions like %yacc. Perhaps there should also be a GCC-style --pedantic-errors option, so that such warnings are diagnosed as errors. */ - if (outer_brace && ! yacc_flag) + if (outer_brace && token_type == BRACED_CODE && ! yacc_flag) obstack_1grow (&obstack_for_string, ';'); obstack_1grow (&obstack_for_string, '}'); @@ -681,14 +681,14 @@ adjust_location (location *loc, char const *token, size_t size) static size_t no_cr_read (FILE *fp, char *buf, size_t size) { - size_t s = fread (buf, 1, size, fp); - if (s) + size_t bytes_read = fread (buf, 1, size, fp); + if (bytes_read) { - char *w = memchr (buf, '\r', s); + char *w = memchr (buf, '\r', bytes_read); if (w) { char const *r = ++w; - char const *lim = buf + s; + char const *lim = buf + bytes_read; for (;;) { @@ -717,7 +717,7 @@ no_cr_read (FILE *fp, char *buf, size_t size) } } - return s; + return bytes_read; }