/[bison]/bison/src/scan-gram.l
ViewVC logotype

Diff of /bison/src/scan-gram.l

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.58 by eggert, Thu Mar 13 07:07:17 2003 UTC revision 1.59 by eggert, Fri Apr 18 07:26:19 2003 UTC
# Line 20  Line 20 
20     02111-1307  USA     02111-1307  USA
21  */  */
22    
23  %option debug nodefault noyywrap never-interactive  %option debug nodefault nounput noyywrap never-interactive
24  %option prefix="gram_" outfile="lex.yy.c"  %option prefix="gram_" outfile="lex.yy.c"
25    
26  %{  %{
# Line 102  static void handle_dollar (int token_typ Line 102  static void handle_dollar (int token_typ
102  static void handle_at (int token_type, char *cp, location loc);  static void handle_at (int token_type, char *cp, location loc);
103  static void handle_syncline (char *args);  static void handle_syncline (char *args);
104  static int convert_ucn_to_byte (char const *hex_text);  static int convert_ucn_to_byte (char const *hex_text);
105  static void unexpected_end_of_file (boundary, char const *);  static void unexpected_eof (boundary, char const *);
106    
107  %}  %}
108  %x SC_COMMENT SC_LINE_COMMENT SC_YACC_COMMENT  %x SC_COMMENT SC_LINE_COMMENT SC_YACC_COMMENT
# Line 323  splice  (\\[ \f\t\v]*\n)* Line 323  splice  (\\[ \f\t\v]*\n)*
323  {  {
324    "*/"     BEGIN context_state;    "*/"     BEGIN context_state;
325    .|\n     ;    .|\n     ;
326    <<EOF>>  unexpected_end_of_file (token_start, "*/");    <<EOF>>  unexpected_eof (token_start, "*/"); BEGIN context_state;
327  }  }
328    
329    
# Line 334  splice  (\\[ \f\t\v]*\n)* Line 334  splice  (\\[ \f\t\v]*\n)*
334  <SC_COMMENT>  <SC_COMMENT>
335  {  {
336    "*"{splice}"/"  STRING_GROW; BEGIN context_state;    "*"{splice}"/"  STRING_GROW; BEGIN context_state;
337    <<EOF>>         unexpected_end_of_file (token_start, "*/");    <<EOF>>         unexpected_eof (token_start, "*/"); BEGIN context_state;
338  }  }
339    
340    
# Line 368  splice  (\\[ \f\t\v]*\n)* Line 368  splice  (\\[ \f\t\v]*\n)*
368    }    }
369    
370    .|\n      STRING_GROW;    .|\n      STRING_GROW;
371    <<EOF>>   unexpected_end_of_file (token_start, "\"");    <<EOF>>   unexpected_eof (token_start, "\""); BEGIN INITIAL;
372  }  }
373    
374    /*---------------------------------------------------------------.    /*---------------------------------------------------------------.
# Line 394  splice  (\\[ \f\t\v]*\n)* Line 394  splice  (\\[ \f\t\v]*\n)*
394    }    }
395    
396    .|\n      STRING_GROW;    .|\n      STRING_GROW;
397    <<EOF>>   unexpected_end_of_file (token_start, "'");    <<EOF>>   unexpected_eof (token_start, "'"); BEGIN INITIAL;
398  }  }
399    
400    
# Line 456  splice  (\\[ \f\t\v]*\n)* Line 456  splice  (\\[ \f\t\v]*\n)*
456  {  {
457    "'"                   STRING_GROW; BEGIN context_state;    "'"                   STRING_GROW; BEGIN context_state;
458    \\{splice}[^$@\[\]]   STRING_GROW;    \\{splice}[^$@\[\]]   STRING_GROW;
459    <<EOF>>               unexpected_end_of_file (token_start, "'");    <<EOF>>               unexpected_eof (token_start, "'"); BEGIN context_state;
460  }  }
461    
462    
# Line 469  splice  (\\[ \f\t\v]*\n)* Line 469  splice  (\\[ \f\t\v]*\n)*
469  {  {
470    "\""                  STRING_GROW; BEGIN context_state;    "\""                  STRING_GROW; BEGIN context_state;
471    \\{splice}[^$@\[\]]   STRING_GROW;    \\{splice}[^$@\[\]]   STRING_GROW;
472    <<EOF>>               unexpected_end_of_file (token_start, "\"");    <<EOF>> {
473        unexpected_eof (token_start, "\"");
474        BEGIN context_state;
475      }
476  }  }
477    
478    
# Line 536  splice  (\\[ \f\t\v]*\n)* Line 539  splice  (\\[ \f\t\v]*\n)*
539        }        }
540    }    }
541    
542    <<EOF>>  unexpected_end_of_file (scanner_cursor, "{}");    <<EOF>>  unexpected_eof (scanner_cursor, "{}"); BEGIN INITIAL;
543  }  }
544    
545    
# Line 589  splice  (\\[ \f\t\v]*\n)* Line 592  splice  (\\[ \f\t\v]*\n)*
592    "$"("<"{tag}">")?(-?[0-9]+|"$")  handle_dollar (token_type, yytext, *loc);    "$"("<"{tag}">")?(-?[0-9]+|"$")  handle_dollar (token_type, yytext, *loc);
593    "@"(-?[0-9]+|"$")                handle_at (token_type, yytext, *loc);    "@"(-?[0-9]+|"$")                handle_at (token_type, yytext, *loc);
594    
595    <<EOF>>  unexpected_end_of_file (code_start, "}");    <<EOF>>  unexpected_eof (code_start, "}"); BEGIN INITIAL;
596  }  }
597    
598    
# Line 607  splice  (\\[ \f\t\v]*\n)* Line 610  splice  (\\[ \f\t\v]*\n)*
610      return PROLOGUE;      return PROLOGUE;
611    }    }
612    
613    <<EOF>>  unexpected_end_of_file (code_start, "%}");    <<EOF>>  unexpected_eof (code_start, "%}"); BEGIN INITIAL;
614  }  }
615    
616    
# Line 971  handle_syncline (char *args) Line 974  handle_syncline (char *args)
974  /*------------------------------------------------------------------------.  /*------------------------------------------------------------------------.
975  | Report an unexpected EOF in a token or comment starting at START.       |  | Report an unexpected EOF in a token or comment starting at START.       |
976  | An end of file was encountered and the expected TOKEN_END was missing.  |  | An end of file was encountered and the expected TOKEN_END was missing.  |
 | After reporting the problem, pretend that TOKEN_END was found.          |  
977  `------------------------------------------------------------------------*/  `------------------------------------------------------------------------*/
978    
979  static void  static void
980  unexpected_end_of_file (boundary start, char const *token_end)  unexpected_eof (boundary start, char const *token_end)
981  {  {
   size_t i = strlen (token_end);  
   
982    location loc;    location loc;
983    loc.start = start;    loc.start = start;
984    loc.end = scanner_cursor;    loc.end = scanner_cursor;
985    complain_at (loc, _("missing `%s' at end of file"), token_end);    complain_at (loc, _("missing `%s' at end of file"), token_end);
   
   /* Adjust scanner cursor so that any later message does not count  
      the characters about to be inserted.  */  
   scanner_cursor.column -= i;  
   
   while (i != 0)  
     unput (token_end[--i]);  
986  }  }
987    
988    

Legend:
Removed from v.1.58  
changed lines
  Added in v.1.59

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26