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 |
%{ |
%{ |
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 |
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 |
|
|
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 |
|
|
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 |
/*---------------------------------------------------------------. |
/*---------------------------------------------------------------. |
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 |
|
|
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 |
|
|
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 |
|
|
539 |
} |
} |
540 |
} |
} |
541 |
|
|
542 |
<<EOF>> unexpected_end_of_file (scanner_cursor, "{}"); |
<<EOF>> unexpected_eof (scanner_cursor, "{}"); BEGIN INITIAL; |
543 |
} |
} |
544 |
|
|
545 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|