<HASH>version{HSPACE}+ {
BEGIN INITIAL;
yyextra->space_tokens = 0;
- RETURN_STRING_TOKEN (HASH_VERSION);
+ RETURN_STRING_TOKEN (VERSION_TOKEN);
}
/* glcpp doesn't handle #extension, #version, or #pragma directives.
BEGIN INITIAL;
yylineno++;
yycolumn = 0;
- RETURN_STRING_TOKEN (HASH_PRAGMA);
+ RETURN_STRING_TOKEN (PRAGMA);
}
<HASH>line{HSPACE}+ {
BEGIN INITIAL;
- RETURN_TOKEN (HASH_LINE);
+ RETURN_TOKEN (LINE);
}
<HASH>\n {
BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (HASH_IFDEF);
+ RETURN_TOKEN_NEVER_SKIP (IFDEF);
}
<HASH>ifndef {
BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (HASH_IFNDEF);
+ RETURN_TOKEN_NEVER_SKIP (IFNDEF);
}
<HASH>if/[^_a-zA-Z0-9] {
BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (HASH_IF);
+ RETURN_TOKEN_NEVER_SKIP (IF);
}
<HASH>elif/[^_a-zA-Z0-9] {
BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (HASH_ELIF);
+ RETURN_TOKEN_NEVER_SKIP (ELIF);
}
<HASH>else {
BEGIN INITIAL;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (HASH_ELSE);
+ RETURN_TOKEN_NEVER_SKIP (ELSE);
}
<HASH>endif {
BEGIN INITIAL;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (HASH_ENDIF);
+ RETURN_TOKEN_NEVER_SKIP (ENDIF);
}
<HASH>error.* {
BEGIN INITIAL;
- RETURN_STRING_TOKEN (HASH_ERROR);
+ RETURN_STRING_TOKEN (ERROR);
}
/* After we see a "#define" we enter the <DEFINE> start state
if (! parser->skipping) {
BEGIN DEFINE;
yyextra->space_tokens = 0;
- RETURN_TOKEN (HASH_DEFINE);
+ RETURN_TOKEN (DEFINE_TOKEN);
}
}
<HASH>undef {
BEGIN INITIAL;
yyextra->space_tokens = 0;
- RETURN_TOKEN (HASH_UNDEF);
+ RETURN_TOKEN (UNDEF);
}
<HASH>{HSPACE}+ {
/* This will catch any non-directive garbage after a HASH */
<HASH>{NONSPACE} {
BEGIN INITIAL;
- RETURN_TOKEN (HASH_GARBAGE);
+ RETURN_TOKEN (GARBAGE);
}
/* An identifier immediately followed by '(' */
%expect 0
- /* We use HASH_TOKEN, not HASH to avoid a conflict with the <HASH>
- * start condition in the lexer. */
-%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH_TOKEN HASH_DEFINE FUNC_IDENTIFIER OBJ_IDENTIFIER HASH_ELIF HASH_ELSE HASH_ENDIF HASH_ERROR HASH_IF HASH_IFDEF HASH_IFNDEF HASH_LINE HASH_PRAGMA HASH_UNDEF HASH_VERSION HASH_GARBAGE IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE
+ /* We use HASH_TOKEN, DEFINE_TOKEN and VERSION_TOKEN (as opposed to
+ * HASH, DEFINE, and VERSION) to avoid conflicts with other symbols,
+ * (such as the <HASH> and <DEFINE> start conditions in the lexer). */
+%token COMMA_FINAL DEFINED ELIF_EXPANDED HASH_TOKEN DEFINE_TOKEN FUNC_IDENTIFIER OBJ_IDENTIFIER ELIF ELSE ENDIF ERROR IF IFDEF IFNDEF LINE PRAGMA UNDEF VERSION_TOKEN GARBAGE IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE
%token PASTE
%type <ival> INTEGER operator SPACE integer_constant
%type <expression_value> expression
-%type <str> IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER HASH_ERROR HASH_PRAGMA
+%type <str> IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER ERROR PRAGMA
%type <string_list> identifier_list
%type <token> preprocessing_token conditional_token
%type <token_list> pp_tokens replacement_list text_line conditional_tokens
ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
}
| control_line_error
-| HASH_TOKEN HASH_LINE {
+| HASH_TOKEN LINE {
glcpp_parser_resolve_implicit_version(parser);
} pp_tokens NEWLINE {
;
control_line_success:
- HASH_TOKEN HASH_DEFINE {
+ HASH_TOKEN DEFINE_TOKEN {
glcpp_parser_resolve_implicit_version(parser);
} define
-| HASH_TOKEN HASH_UNDEF {
+| HASH_TOKEN UNDEF {
glcpp_parser_resolve_implicit_version(parser);
} IDENTIFIER NEWLINE {
macro_t *macro;
}
ralloc_free ($4);
}
-| HASH_TOKEN HASH_IF {
+| HASH_TOKEN IF {
glcpp_parser_resolve_implicit_version(parser);
} conditional_tokens NEWLINE {
/* Be careful to only evaluate the 'if' expression if
parser->skip_stack->type = SKIP_TO_ENDIF;
}
}
-| HASH_TOKEN HASH_IF NEWLINE {
+| HASH_TOKEN IF NEWLINE {
/* #if without an expression is only an error if we
* are not skipping */
if (parser->skip_stack == NULL ||
}
_glcpp_parser_skip_stack_push_if (parser, & @1, 0);
}
-| HASH_TOKEN HASH_IFDEF {
+| HASH_TOKEN IFDEF {
glcpp_parser_resolve_implicit_version(parser);
} IDENTIFIER junk NEWLINE {
macro_t *macro = hash_table_find (parser->defines, $4);
ralloc_free ($4);
_glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
}
-| HASH_TOKEN HASH_IFNDEF {
+| HASH_TOKEN IFNDEF {
glcpp_parser_resolve_implicit_version(parser);
} IDENTIFIER junk NEWLINE {
macro_t *macro = hash_table_find (parser->defines, $4);
ralloc_free ($4);
_glcpp_parser_skip_stack_push_if (parser, & @3, macro == NULL);
}
-| HASH_TOKEN HASH_ELIF conditional_tokens NEWLINE {
+| HASH_TOKEN ELIF conditional_tokens NEWLINE {
/* Be careful to only evaluate the 'elif' expression
* if we are not skipping. When we are skipping, we
* simply change to a 0-valued 'elif' on the skip
"elif", 0);
}
}
-| HASH_TOKEN HASH_ELIF NEWLINE {
+| HASH_TOKEN ELIF NEWLINE {
/* #elif without an expression is an error unless we
* are skipping. */
if (parser->skip_stack &&
glcpp_warning(& @1, parser, "ignoring illegal #elif without expression");
}
}
-| HASH_TOKEN HASH_ELSE { parser->lexing_directive = 1; } NEWLINE {
+| HASH_TOKEN ELSE { parser->lexing_directive = 1; } NEWLINE {
if (parser->skip_stack &&
parser->skip_stack->has_else)
{
parser->skip_stack->has_else = true;
}
}
-| HASH_TOKEN HASH_ENDIF {
+| HASH_TOKEN ENDIF {
_glcpp_parser_skip_stack_pop (parser, & @1);
} NEWLINE
-| HASH_TOKEN HASH_VERSION integer_constant NEWLINE {
+| HASH_TOKEN VERSION_TOKEN integer_constant NEWLINE {
if (parser->version_resolved) {
glcpp_error(& @1, parser, "#version must appear on the first line");
}
_glcpp_parser_handle_version_declaration(parser, $3, NULL, true);
}
-| HASH_TOKEN HASH_VERSION integer_constant IDENTIFIER NEWLINE {
+| HASH_TOKEN VERSION_TOKEN integer_constant IDENTIFIER NEWLINE {
if (parser->version_resolved) {
glcpp_error(& @1, parser, "#version must appear on the first line");
}
| HASH_TOKEN NEWLINE {
glcpp_parser_resolve_implicit_version(parser);
}
-| HASH_TOKEN HASH_PRAGMA NEWLINE {
+| HASH_TOKEN PRAGMA NEWLINE {
ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "#%s", $2);
}
;
control_line_error:
- HASH_TOKEN HASH_ERROR NEWLINE {
+ HASH_TOKEN ERROR NEWLINE {
glcpp_error(& @1, parser, "#%s", $2);
}
-| HASH_TOKEN HASH_GARBAGE pp_tokens NEWLINE {
+| HASH_TOKEN GARBAGE pp_tokens NEWLINE {
glcpp_error (& @1, parser, "Illegal non-directive after #");
}
;
if (ret == NEWLINE)
parser->in_control_line = 0;
}
- else if (ret == HASH_DEFINE ||
- ret == HASH_UNDEF || ret == HASH_IF ||
- ret == HASH_IFDEF || ret == HASH_IFNDEF ||
- ret == HASH_ELIF || ret == HASH_ELSE ||
- ret == HASH_ENDIF || ret == HASH_TOKEN)
+ else if (ret == DEFINE_TOKEN ||
+ ret == UNDEF || ret == IF ||
+ ret == IFDEF || ret == IFNDEF ||
+ ret == ELIF || ret == ELSE ||
+ ret == ENDIF || ret == HASH_TOKEN)
{
parser->in_control_line = 1;
}