static int
glcpp_lex_update_state_per_token (glcpp_parser_t *parser, int token)
{
+ if (token != NEWLINE && token != SPACE && token != HASH_TOKEN &&
+ !parser->lexing_version_directive) {
+ glcpp_parser_resolve_implicit_version(parser);
+ }
+
/* After the first non-space token in a line, we won't
* allow any '#' to introduce a directive. */
if (token == NEWLINE) {
<HASH>version{HSPACE}+ {
BEGIN INITIAL;
yyextra->space_tokens = 0;
+ yyextra->lexing_version_directive = 1;
RETURN_STRING_TOKEN (VERSION_TOKEN);
}
}
yyextra->space_tokens = 1;
yyextra->lexing_directive = 0;
+ yyextra->lexing_version_directive = 0;
yylineno++;
yycolumn = 0;
RETURN_TOKEN_NEVER_SKIP (NEWLINE);
glcpp_error(yylloc, yyextra, "Unterminated comment");
BEGIN DONE; /* Don't keep matching this rule forever. */
yyextra->lexing_directive = 0;
+ yyextra->lexing_version_directive = 0;
if (! parser->last_token_was_newline)
RETURN_TOKEN (NEWLINE);
}
struct hash_table *defines;
active_list_t *active;
int lexing_directive;
+ int lexing_version_directive;
int space_tokens;
int last_token_was_newline;
int last_token_was_space;