[Mesa-dev] [PATCH] glsl/glcp: Rename all token names to have a _TOK suffix
Carl Worth
cworth at cworth.org
Wed Jul 30 09:29:12 PDT 2014
Previously, we tried to have unadorned token names, (NEWLINE, SPACE, PASTE,
etc.). But occasionally we would run into conflicts with lexer start
conditions or with system header files that would define identical symbols,
(such as the lexer start condition HASH or a Windows header symbol ERROR).
As these various conflicts were encountered, some of the token names were
given an _TOKEN suffix. But this was inconsistently applied, (only to those
symbols that had caused an actual conflict).
With this commit we make things consistent by applying a suffix to all token
names. We use _TOK instead of _TOKEN to save some columns, (and to be
consistent with the suffix used in the main glsl compiler).
There is no intended behavioral change with this commit, (other than the
slight change to some parser error messages as can be seen in the updated
cases in the "make check" test suite for glcpp).
---
src/glsl/glcpp/glcpp-lex.l | 94 ++---
src/glsl/glcpp/glcpp-parse.y | 387 +++++++++++----------
.../glcpp/tests/102-garbage-after-endif.c.expected | 2 +-
.../tests/103-garbage-after-else-0.c.expected | 2 +-
.../tests/123-garbage-after-else-1.c.expected | 2 +-
.../tests/129-define-non-identifier.c.expected | 2 +-
.../tests/136-plus-plus-and-minus-minus.c.expected | 2 +-
7 files changed, 246 insertions(+), 245 deletions(-)
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index 98d500e..6c50571 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -122,23 +122,23 @@ glcpp_lex_update_state_per_token (glcpp_parser_t *parser, int token)
{
/* After the first non-space token in a line, we won't
* allow any '#' to introduce a directive. */
- if (token == NEWLINE) {
+ if (token == NEWLINE_TOK) {
parser->first_non_space_token_this_line = 1;
- } else if (token != SPACE) {
+ } else if (token != SPACE_TOK) {
parser->first_non_space_token_this_line = 0;
}
/* Track newlines just to know whether a newline needs
* to be inserted if end-of-file comes early. */
- if (token == NEWLINE) {
+ if (token == NEWLINE_TOK) {
parser->last_token_was_newline = 1;
} else {
parser->last_token_was_newline = 0;
}
- /* Track spaces to avoid emitting multiple SPACE
+ /* Track spaces to avoid emitting multiple SPACE_TOK
* tokens in a row. */
- if (token == SPACE) {
+ if (token == SPACE_TOK) {
if (! parser->last_token_was_space) {
parser->last_token_was_space = 1;
return 1;
@@ -209,7 +209,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
parser->commented_newlines--;
if (parser->commented_newlines == 0)
BEGIN INITIAL;
- RETURN_TOKEN_NEVER_SKIP (NEWLINE);
+ RETURN_TOKEN_NEVER_SKIP (NEWLINE_TOK);
}
/* Set up the parser->skipping bit here before doing any lexing.
@@ -264,7 +264,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
yy_pop_state(yyscanner);
/* In the <HASH> start condition, we don't want any SPACE token. */
if (yyextra->space_tokens && YY_START != HASH)
- RETURN_TOKEN (SPACE);
+ RETURN_TOKEN (SPACE_TOK);
}
{HASH} {
@@ -279,13 +279,13 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
BEGIN HASH;
}
- RETURN_TOKEN_NEVER_SKIP (HASH_TOKEN);
+ RETURN_TOKEN_NEVER_SKIP (HASH_TOK);
}
<HASH>version{HSPACE}+ {
BEGIN INITIAL;
yyextra->space_tokens = 0;
- RETURN_STRING_TOKEN (VERSION_TOKEN);
+ RETURN_STRING_TOKEN (VERSION_TOK);
}
/* Swallow empty #pragma directives, (to avoid confusing the
@@ -298,17 +298,17 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
* Simply pass them through to the main compiler's lexer/parser. */
<HASH>(extension|pragma)[^\r\n]* {
BEGIN INITIAL;
- RETURN_STRING_TOKEN (PRAGMA);
+ RETURN_STRING_TOKEN (PRAGMA_TOK);
}
<HASH>line{HSPACE}+ {
BEGIN INITIAL;
- RETURN_TOKEN (LINE);
+ RETURN_TOKEN (LINE_TOK);
}
<HASH>{NEWLINE} {
BEGIN INITIAL;
- RETURN_TOKEN_NEVER_SKIP (NEWLINE);
+ RETURN_TOKEN_NEVER_SKIP (NEWLINE_TOK);
}
/* For the pre-processor directives, we return these tokens
@@ -317,45 +317,45 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (IFDEF);
+ RETURN_TOKEN_NEVER_SKIP (IFDEF_TOK);
}
<HASH>ifndef {
BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (IFNDEF);
+ RETURN_TOKEN_NEVER_SKIP (IFNDEF_TOK);
}
<HASH>if/[^_a-zA-Z0-9] {
BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (IF);
+ RETURN_TOKEN_NEVER_SKIP (IF_TOK);
}
<HASH>elif/[^_a-zA-Z0-9] {
BEGIN INITIAL;
yyextra->lexing_directive = 1;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (ELIF);
+ RETURN_TOKEN_NEVER_SKIP (ELIF_TOK);
}
<HASH>else {
BEGIN INITIAL;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (ELSE);
+ RETURN_TOKEN_NEVER_SKIP (ELSE_TOK);
}
<HASH>endif {
BEGIN INITIAL;
yyextra->space_tokens = 0;
- RETURN_TOKEN_NEVER_SKIP (ENDIF);
+ RETURN_TOKEN_NEVER_SKIP (ENDIF_TOK);
}
<HASH>error[^\r\n]* {
BEGIN INITIAL;
- RETURN_STRING_TOKEN (ERROR_TOKEN);
+ RETURN_STRING_TOKEN (ERROR_TOK);
}
/* After we see a "#define" we enter the <DEFINE> start state
@@ -380,14 +380,14 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
if (! parser->skipping) {
BEGIN DEFINE;
yyextra->space_tokens = 0;
- RETURN_TOKEN (DEFINE_TOKEN);
+ RETURN_TOKEN (DEFINE_TOK);
}
}
<HASH>undef {
BEGIN INITIAL;
yyextra->space_tokens = 0;
- RETURN_TOKEN (UNDEF);
+ RETURN_TOKEN (UNDEF_TOK);
}
<HASH>{HSPACE}+ {
@@ -399,19 +399,19 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
/* This will catch any non-directive garbage after a HASH */
<HASH>{NONSPACE} {
BEGIN INITIAL;
- RETURN_TOKEN (GARBAGE);
+ RETURN_TOKEN (GARBAGE_TOK);
}
/* An identifier immediately followed by '(' */
<DEFINE>{IDENTIFIER}/"(" {
BEGIN INITIAL;
- RETURN_STRING_TOKEN (FUNC_IDENTIFIER);
+ RETURN_STRING_TOKEN (FUNC_IDENTIFIER_TOK);
}
/* An identifier not immediately followed by '(' */
<DEFINE>{IDENTIFIER} {
BEGIN INITIAL;
- RETURN_STRING_TOKEN (OBJ_IDENTIFIER);
+ RETURN_STRING_TOKEN (OBJ_IDENTIFIER_TOK);
}
/* Whitespace */
@@ -423,7 +423,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
<DEFINE>[/][^*]{NONSPACE}* {
BEGIN INITIAL;
glcpp_error(yylloc, yyextra, "#define followed by a non-identifier: %s", yytext);
- RETURN_STRING_TOKEN (INTEGER_STRING);
+ RETURN_STRING_TOKEN (INTEGER_STRING_TOK);
}
/* A character that can't start an identifier, comment, or
@@ -431,79 +431,79 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
<DEFINE>[^_a-zA-Z/[:space:]]{NONSPACE}* {
BEGIN INITIAL;
glcpp_error(yylloc, yyextra, "#define followed by a non-identifier: %s", yytext);
- RETURN_STRING_TOKEN (INTEGER_STRING);
+ RETURN_STRING_TOKEN (INTEGER_STRING_TOK);
}
{DECIMAL_INTEGER} {
- RETURN_STRING_TOKEN (INTEGER_STRING);
+ RETURN_STRING_TOKEN (INTEGER_STRING_TOK);
}
{OCTAL_INTEGER} {
- RETURN_STRING_TOKEN (INTEGER_STRING);
+ RETURN_STRING_TOKEN (INTEGER_STRING_TOK);
}
{HEXADECIMAL_INTEGER} {
- RETURN_STRING_TOKEN (INTEGER_STRING);
+ RETURN_STRING_TOKEN (INTEGER_STRING_TOK);
}
"<<" {
- RETURN_TOKEN (LEFT_SHIFT);
+ RETURN_TOKEN (LEFT_SHIFT_TOK);
}
">>" {
- RETURN_TOKEN (RIGHT_SHIFT);
+ RETURN_TOKEN (RIGHT_SHIFT_TOK);
}
"<=" {
- RETURN_TOKEN (LESS_OR_EQUAL);
+ RETURN_TOKEN (LESS_OR_EQUAL_TOK);
}
">=" {
- RETURN_TOKEN (GREATER_OR_EQUAL);
+ RETURN_TOKEN (GREATER_OR_EQUAL_TOK);
}
"==" {
- RETURN_TOKEN (EQUAL);
+ RETURN_TOKEN (EQUAL_TOK);
}
"!=" {
- RETURN_TOKEN (NOT_EQUAL);
+ RETURN_TOKEN (NOT_EQUAL_TOK);
}
"&&" {
- RETURN_TOKEN (AND);
+ RETURN_TOKEN (AND_TOK);
}
"||" {
- RETURN_TOKEN (OR);
+ RETURN_TOKEN (OR_TOK);
}
"++" {
- RETURN_TOKEN (PLUS_PLUS);
+ RETURN_TOKEN (PLUS_PLUS_TOK);
}
"--" {
- RETURN_TOKEN (MINUS_MINUS);
+ RETURN_TOKEN (MINUS_MINUS_TOK);
}
"##" {
if (! parser->skipping) {
if (parser->is_gles)
glcpp_error(yylloc, yyextra, "Token pasting (##) is illegal in GLES");
- RETURN_TOKEN (PASTE);
+ RETURN_TOKEN (PASTE_TOK);
}
}
"defined" {
- RETURN_TOKEN (DEFINED);
+ RETURN_TOKEN (DEFINED_TOK);
}
{IDENTIFIER} {
- RETURN_STRING_TOKEN (IDENTIFIER);
+ RETURN_STRING_TOKEN (IDENTIFIER_TOK);
}
{PP_NUMBER} {
- RETURN_STRING_TOKEN (OTHER);
+ RETURN_STRING_TOKEN (OTHER_TOK);
}
{PUNCTUATION} {
@@ -511,12 +511,12 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
}
{OTHER}+ {
- RETURN_STRING_TOKEN (OTHER);
+ RETURN_STRING_TOKEN (OTHER_TOK);
}
{HSPACE} {
if (yyextra->space_tokens) {
- RETURN_TOKEN (SPACE);
+ RETURN_TOKEN (SPACE_TOK);
}
}
@@ -532,7 +532,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
yyextra->lexing_directive = 0;
yylineno++;
yycolumn = 0;
- RETURN_TOKEN_NEVER_SKIP (NEWLINE);
+ RETURN_TOKEN_NEVER_SKIP (NEWLINE_TOK);
}
<INITIAL,COMMENT,DEFINE,HASH><<EOF>> {
@@ -541,7 +541,7 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
BEGIN DONE; /* Don't keep matching this rule forever. */
yyextra->lexing_directive = 0;
if (! parser->last_token_was_newline)
- RETURN_TOKEN (NEWLINE);
+ RETURN_TOKEN (NEWLINE_TOK);
}
/* This is a catch-all to avoid the annoying default flex action which
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 9a223ae..450e6f9 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -175,28 +175,29 @@ add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
%expect 0
- /* 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 DEFINED ELIF_EXPANDED HASH_TOKEN DEFINE_TOKEN FUNC_IDENTIFIER OBJ_IDENTIFIER ELIF ELSE ENDIF ERROR_TOKEN IF IFDEF IFNDEF LINE PRAGMA UNDEF VERSION_TOKEN GARBAGE IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE PLUS_PLUS MINUS_MINUS
-%token PASTE
-%type <ival> INTEGER operator SPACE integer_constant
+%token DEFINE_TOK DEFINED_TOK ELIF_TOK ELIF_EXPANDED_TOK ELSE_TOK ENDIF_TOK
+%token ERROR_TOK FUNC_IDENTIFIER_TOK GARBAGE_TOK HASH_TOK IDENTIFIER_TOK
+%token IF_TOK IF_EXPANDED_TOK IFDEF_TOK IFNDEF_TOK INTEGER_TOK
+%token INTEGER_STRING_TOK LINE_TOK LINE_EXPANDED_TOK MINUS_MINUS_TOK
+%token NEWLINE_TOK OBJ_IDENTIFIER_TOK OTHER_TOK PASTE_TOK PLACEHOLDER_TOK
+%token PLUS_PLUS_TOK PRAGMA_TOK SPACE_TOK UNDEF_TOK VERSION_TOK
+%type <ival> INTEGER_TOK operator SPACE_TOK integer_constant
%type <expression_value> expression
-%type <str> IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER ERROR_TOKEN PRAGMA
+%type <str> IDENTIFIER_TOK FUNC_IDENTIFIER_TOK OBJ_IDENTIFIER_TOK INTEGER_STRING_TOK OTHER_TOK ERROR_TOK PRAGMA_TOK
%type <string_list> identifier_list
%type <token> preprocessing_token
%type <token_list> pp_tokens replacement_list text_line
-%left OR
-%left AND
+%left OR_TOK
+%left AND_TOK
%left '|'
%left '^'
%left '&'
-%left EQUAL NOT_EQUAL
-%left '<' '>' LESS_OR_EQUAL GREATER_OR_EQUAL
-%left LEFT_SHIFT RIGHT_SHIFT
+%left EQUAL_TOK NOT_EQUAL_TOK
+%left '<' '>' LESS_OR_EQUAL_TOK GREATER_OR_EQUAL_TOK
+%left LEFT_SHIFT_TOK RIGHT_SHIFT_TOK
%left '+' '-'
%left '*' '/' '%'
-%right UNARY
+%right UNARY_TOK
%debug
@@ -209,7 +210,7 @@ input:
line:
control_line
-| SPACE control_line
+| SPACE_TOK control_line
| text_line {
_glcpp_parser_print_expanded_token_list (parser, $1);
ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
@@ -219,17 +220,17 @@ line:
;
expanded_line:
- IF_EXPANDED expression NEWLINE {
+ IF_EXPANDED_TOK expression NEWLINE_TOK {
if (parser->is_gles && $2.undefined_macro)
glcpp_error(& @1, parser, "undefined macro %s in expression (illegal in GLES)", $2.undefined_macro);
_glcpp_parser_skip_stack_push_if (parser, & @1, $2.value);
}
-| ELIF_EXPANDED expression NEWLINE {
+| ELIF_EXPANDED_TOK expression NEWLINE_TOK {
if (parser->is_gles && $2.undefined_macro)
glcpp_error(& @1, parser, "undefined macro %s in expression (illegal in GLES)", $2.undefined_macro);
_glcpp_parser_skip_stack_change_if (parser, & @1, "elif", $2.value);
}
-| LINE_EXPANDED integer_constant NEWLINE {
+| LINE_EXPANDED_TOK integer_constant NEWLINE_TOK {
parser->has_new_line_number = 1;
parser->new_line_number = $2;
ralloc_asprintf_rewrite_tail (&parser->output,
@@ -237,7 +238,7 @@ expanded_line:
"#line %" PRIiMAX "\n",
$2);
}
-| LINE_EXPANDED integer_constant integer_constant NEWLINE {
+| LINE_EXPANDED_TOK integer_constant integer_constant NEWLINE_TOK {
parser->has_new_line_number = 1;
parser->new_line_number = $2;
parser->has_new_source_number = 1;
@@ -250,13 +251,13 @@ expanded_line:
;
define:
- OBJ_IDENTIFIER replacement_list NEWLINE {
+ OBJ_IDENTIFIER_TOK replacement_list NEWLINE_TOK {
_define_object_macro (parser, & @1, $1, $2);
}
-| FUNC_IDENTIFIER '(' ')' replacement_list NEWLINE {
+| FUNC_IDENTIFIER_TOK '(' ')' replacement_list NEWLINE_TOK {
_define_function_macro (parser, & @1, $1, NULL, $4);
}
-| FUNC_IDENTIFIER '(' identifier_list ')' replacement_list NEWLINE {
+| FUNC_IDENTIFIER_TOK '(' identifier_list ')' replacement_list NEWLINE_TOK {
_define_function_macro (parser, & @1, $1, $3, $5);
}
;
@@ -266,27 +267,27 @@ control_line:
ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
}
| control_line_error
-| HASH_TOKEN LINE {
+| HASH_TOK LINE_TOK {
glcpp_parser_resolve_implicit_version(parser);
- } pp_tokens NEWLINE {
+ } pp_tokens NEWLINE_TOK {
if (parser->skip_stack == NULL ||
parser->skip_stack->type == SKIP_NO_SKIP)
{
_glcpp_parser_expand_and_lex_from (parser,
- LINE_EXPANDED, $4,
+ LINE_EXPANDED_TOK, $4,
EXPANSION_MODE_IGNORE_DEFINED);
}
}
;
control_line_success:
- HASH_TOKEN DEFINE_TOKEN {
+ HASH_TOK DEFINE_TOK {
glcpp_parser_resolve_implicit_version(parser);
} define
-| HASH_TOKEN UNDEF {
+| HASH_TOK UNDEF_TOK {
glcpp_parser_resolve_implicit_version(parser);
- } IDENTIFIER NEWLINE {
+ } IDENTIFIER_TOK NEWLINE_TOK {
macro_t *macro;
if (strcmp("__LINE__", $4) == 0
|| strcmp("__FILE__", $4) == 0
@@ -301,9 +302,9 @@ control_line_success:
}
ralloc_free ($4);
}
-| HASH_TOKEN IF {
+| HASH_TOK IF_TOK {
glcpp_parser_resolve_implicit_version(parser);
- } pp_tokens NEWLINE {
+ } pp_tokens NEWLINE_TOK {
/* Be careful to only evaluate the 'if' expression if
* we are not skipping. When we are skipping, we
* simply push a new 0-valued 'if' onto the skip
@@ -315,7 +316,7 @@ control_line_success:
parser->skip_stack->type == SKIP_NO_SKIP)
{
_glcpp_parser_expand_and_lex_from (parser,
- IF_EXPANDED, $4,
+ IF_EXPANDED_TOK, $4,
EXPANSION_MODE_EVALUATE_DEFINED);
}
else
@@ -324,7 +325,7 @@ control_line_success:
parser->skip_stack->type = SKIP_TO_ENDIF;
}
}
-| HASH_TOKEN IF NEWLINE {
+| HASH_TOK IF_TOK NEWLINE_TOK {
/* #if without an expression is only an error if we
* are not skipping */
if (parser->skip_stack == NULL ||
@@ -334,21 +335,21 @@ control_line_success:
}
_glcpp_parser_skip_stack_push_if (parser, & @1, 0);
}
-| HASH_TOKEN IFDEF {
+| HASH_TOK IFDEF_TOK {
glcpp_parser_resolve_implicit_version(parser);
- } IDENTIFIER junk NEWLINE {
+ } IDENTIFIER_TOK junk NEWLINE_TOK {
macro_t *macro = hash_table_find (parser->defines, $4);
ralloc_free ($4);
_glcpp_parser_skip_stack_push_if (parser, & @1, macro != NULL);
}
-| HASH_TOKEN IFNDEF {
+| HASH_TOK IFNDEF_TOK {
glcpp_parser_resolve_implicit_version(parser);
- } IDENTIFIER junk NEWLINE {
+ } IDENTIFIER_TOK junk NEWLINE_TOK {
macro_t *macro = hash_table_find (parser->defines, $4);
ralloc_free ($4);
_glcpp_parser_skip_stack_push_if (parser, & @3, macro == NULL);
}
-| HASH_TOKEN ELIF pp_tokens NEWLINE {
+| HASH_TOK ELIF_TOK pp_tokens NEWLINE_TOK {
/* 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
@@ -360,7 +361,7 @@ control_line_success:
parser->skip_stack->type == SKIP_TO_ELSE)
{
_glcpp_parser_expand_and_lex_from (parser,
- ELIF_EXPANDED, $3,
+ ELIF_EXPANDED_TOK, $3,
EXPANSION_MODE_EVALUATE_DEFINED);
}
else if (parser->skip_stack &&
@@ -374,7 +375,7 @@ control_line_success:
"elif", 0);
}
}
-| HASH_TOKEN ELIF NEWLINE {
+| HASH_TOK ELIF_TOK NEWLINE_TOK {
/* #elif without an expression is an error unless we
* are skipping. */
if (parser->skip_stack &&
@@ -394,7 +395,7 @@ control_line_success:
glcpp_warning(& @1, parser, "ignoring illegal #elif without expression");
}
}
-| HASH_TOKEN ELSE { parser->lexing_directive = 1; } NEWLINE {
+| HASH_TOK ELSE_TOK { parser->lexing_directive = 1; } NEWLINE_TOK {
if (parser->skip_stack &&
parser->skip_stack->has_else)
{
@@ -407,43 +408,43 @@ control_line_success:
parser->skip_stack->has_else = true;
}
}
-| HASH_TOKEN ENDIF {
+| HASH_TOK ENDIF_TOK {
_glcpp_parser_skip_stack_pop (parser, & @1);
- } NEWLINE
-| HASH_TOKEN VERSION_TOKEN integer_constant NEWLINE {
+ } NEWLINE_TOK
+| HASH_TOK VERSION_TOK integer_constant NEWLINE_TOK {
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 VERSION_TOKEN integer_constant IDENTIFIER NEWLINE {
+| HASH_TOK VERSION_TOK integer_constant IDENTIFIER_TOK NEWLINE_TOK {
if (parser->version_resolved) {
glcpp_error(& @1, parser, "#version must appear on the first line");
}
_glcpp_parser_handle_version_declaration(parser, $3, $4, true);
}
-| HASH_TOKEN NEWLINE {
+| HASH_TOK NEWLINE_TOK {
glcpp_parser_resolve_implicit_version(parser);
}
-| HASH_TOKEN PRAGMA NEWLINE {
+| HASH_TOK PRAGMA_TOK NEWLINE_TOK {
ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "#%s", $2);
}
;
control_line_error:
- HASH_TOKEN ERROR_TOKEN NEWLINE {
+ HASH_TOK ERROR_TOK NEWLINE_TOK {
glcpp_error(& @1, parser, "#%s", $2);
}
-| HASH_TOKEN DEFINE_TOKEN NEWLINE {
+| HASH_TOK DEFINE_TOK NEWLINE_TOK {
glcpp_error (& @1, parser, "#define without macro name");
}
-| HASH_TOKEN GARBAGE pp_tokens NEWLINE {
+| HASH_TOK GARBAGE_TOK pp_tokens NEWLINE_TOK {
glcpp_error (& @1, parser, "Illegal non-directive after #");
}
;
integer_constant:
- INTEGER_STRING {
+ INTEGER_STRING_TOK {
if (strlen ($1) >= 3 && strncmp ($1, "0x", 2) == 0) {
$$ = strtoll ($1 + 2, NULL, 16);
} else if ($1[0] == '0') {
@@ -452,7 +453,7 @@ integer_constant:
$$ = strtoll ($1, NULL, 10);
}
}
-| INTEGER {
+| INTEGER_TOK {
$$ = $1;
}
@@ -461,14 +462,14 @@ expression:
$$.value = $1;
$$.undefined_macro = NULL;
}
-| IDENTIFIER {
+| IDENTIFIER_TOK {
$$.value = 0;
if (parser->is_gles)
$$.undefined_macro = ralloc_strdup (parser, $1);
else
$$.undefined_macro = NULL;
}
-| expression OR expression {
+| expression OR_TOK expression {
$$.value = $1.value || $3.value;
/* Short-circuit: Only flag undefined from right side
@@ -479,7 +480,7 @@ expression:
else if (! $1.value)
$$.undefined_macro = $3.undefined_macro;
}
-| expression AND expression {
+| expression AND_TOK expression {
$$.value = $1.value && $3.value;
/* Short-circuit: Only flag undefined from right-side
@@ -511,28 +512,28 @@ expression:
else
$$.undefined_macro = $3.undefined_macro;
}
-| expression NOT_EQUAL expression {
+| expression NOT_EQUAL_TOK expression {
$$.value = $1.value != $3.value;
if ($1.undefined_macro)
$$.undefined_macro = $1.undefined_macro;
else
$$.undefined_macro = $3.undefined_macro;
}
-| expression EQUAL expression {
+| expression EQUAL_TOK expression {
$$.value = $1.value == $3.value;
if ($1.undefined_macro)
$$.undefined_macro = $1.undefined_macro;
else
$$.undefined_macro = $3.undefined_macro;
}
-| expression GREATER_OR_EQUAL expression {
+| expression GREATER_OR_EQUAL_TOK expression {
$$.value = $1.value >= $3.value;
if ($1.undefined_macro)
$$.undefined_macro = $1.undefined_macro;
else
$$.undefined_macro = $3.undefined_macro;
}
-| expression LESS_OR_EQUAL expression {
+| expression LESS_OR_EQUAL_TOK expression {
$$.value = $1.value <= $3.value;
if ($1.undefined_macro)
$$.undefined_macro = $1.undefined_macro;
@@ -553,14 +554,14 @@ expression:
else
$$.undefined_macro = $3.undefined_macro;
}
-| expression RIGHT_SHIFT expression {
+| expression RIGHT_SHIFT_TOK expression {
$$.value = $1.value >> $3.value;
if ($1.undefined_macro)
$$.undefined_macro = $1.undefined_macro;
else
$$.undefined_macro = $3.undefined_macro;
}
-| expression LEFT_SHIFT expression {
+| expression LEFT_SHIFT_TOK expression {
$$.value = $1.value << $3.value;
if ($1.undefined_macro)
$$.undefined_macro = $1.undefined_macro;
@@ -612,19 +613,19 @@ expression:
else
$$.undefined_macro = $3.undefined_macro;
}
-| '!' expression %prec UNARY {
+| '!' expression %prec UNARY_TOK {
$$.value = ! $2.value;
$$.undefined_macro = $2.undefined_macro;
}
-| '~' expression %prec UNARY {
+| '~' expression %prec UNARY_TOK {
$$.value = ~ $2.value;
$$.undefined_macro = $2.undefined_macro;
}
-| '-' expression %prec UNARY {
+| '-' expression %prec UNARY_TOK {
$$.value = - $2.value;
$$.undefined_macro = $2.undefined_macro;
}
-| '+' expression %prec UNARY {
+| '+' expression %prec UNARY_TOK {
$$.value = + $2.value;
$$.undefined_macro = $2.undefined_macro;
}
@@ -634,12 +635,12 @@ expression:
;
identifier_list:
- IDENTIFIER {
+ IDENTIFIER_TOK {
$$ = _string_list_create (parser);
_string_list_append_item ($$, $1);
ralloc_steal ($$, $1);
}
-| identifier_list ',' IDENTIFIER {
+| identifier_list ',' IDENTIFIER_TOK {
$$ = $1;
_string_list_append_item ($$, $3);
ralloc_steal ($$, $3);
@@ -647,8 +648,8 @@ identifier_list:
;
text_line:
- NEWLINE { $$ = NULL; }
-| pp_tokens NEWLINE
+ NEWLINE_TOK { $$ = NULL; }
+| pp_tokens NEWLINE_TOK
;
replacement_list:
@@ -676,28 +677,28 @@ pp_tokens:
;
preprocessing_token:
- IDENTIFIER {
- $$ = _token_create_str (parser, IDENTIFIER, $1);
+ IDENTIFIER_TOK {
+ $$ = _token_create_str (parser, IDENTIFIER_TOK, $1);
$$->location = yylloc;
}
-| INTEGER_STRING {
- $$ = _token_create_str (parser, INTEGER_STRING, $1);
+| INTEGER_STRING_TOK {
+ $$ = _token_create_str (parser, INTEGER_STRING_TOK, $1);
$$->location = yylloc;
}
| operator {
$$ = _token_create_ival (parser, $1, $1);
$$->location = yylloc;
}
-| DEFINED {
- $$ = _token_create_ival (parser, DEFINED, DEFINED);
+| DEFINED_TOK {
+ $$ = _token_create_ival (parser, DEFINED_TOK, DEFINED_TOK);
$$->location = yylloc;
}
-| OTHER {
- $$ = _token_create_str (parser, OTHER, $1);
+| OTHER_TOK {
+ $$ = _token_create_str (parser, OTHER_TOK, $1);
$$->location = yylloc;
}
-| SPACE {
- $$ = _token_create_ival (parser, SPACE, SPACE);
+| SPACE_TOK {
+ $$ = _token_create_ival (parser, SPACE_TOK, SPACE_TOK);
$$->location = yylloc;
}
;
@@ -718,24 +719,24 @@ operator:
| '!' { $$ = '!'; }
| '/' { $$ = '/'; }
| '%' { $$ = '%'; }
-| LEFT_SHIFT { $$ = LEFT_SHIFT; }
-| RIGHT_SHIFT { $$ = RIGHT_SHIFT; }
+| LEFT_SHIFT_TOK { $$ = LEFT_SHIFT_TOK; }
+| RIGHT_SHIFT_TOK { $$ = RIGHT_SHIFT_TOK; }
| '<' { $$ = '<'; }
| '>' { $$ = '>'; }
-| LESS_OR_EQUAL { $$ = LESS_OR_EQUAL; }
-| GREATER_OR_EQUAL { $$ = GREATER_OR_EQUAL; }
-| EQUAL { $$ = EQUAL; }
-| NOT_EQUAL { $$ = NOT_EQUAL; }
+| LESS_OR_EQUAL_TOK { $$ = LESS_OR_EQUAL_TOK; }
+| GREATER_OR_EQUAL_TOK { $$ = GREATER_OR_EQUAL_TOK; }
+| EQUAL_TOK { $$ = EQUAL_TOK; }
+| NOT_EQUAL_TOK { $$ = NOT_EQUAL_TOK; }
| '^' { $$ = '^'; }
| '|' { $$ = '|'; }
-| AND { $$ = AND; }
-| OR { $$ = OR; }
+| AND_TOK { $$ = AND_TOK; }
+| OR_TOK { $$ = OR_TOK; }
| ';' { $$ = ';'; }
| ',' { $$ = ','; }
| '=' { $$ = '='; }
-| PASTE { $$ = PASTE; }
-| PLUS_PLUS { $$ = PLUS_PLUS; }
-| MINUS_MINUS { $$ = MINUS_MINUS; }
+| PASTE_TOK { $$ = PASTE_TOK; }
+| PLUS_PLUS_TOK { $$ = PLUS_PLUS_TOK; }
+| MINUS_MINUS_TOK { $$ = MINUS_MINUS_TOK; }
;
%%
@@ -974,7 +975,7 @@ _token_list_append (token_list_t *list, token_t *token)
}
list->tail = node;
- if (token->type != SPACE)
+ if (token->type != SPACE_TOK)
list->non_space_tail = node;
}
@@ -1040,7 +1041,7 @@ _token_list_is_empty_ignoring_space (token_list_t *l)
return 1;
n = l->head;
- while (n != NULL && n->token->type == SPACE)
+ while (n != NULL && n->token->type == SPACE_TOK)
n = n->next;
return n == NULL;
@@ -1071,11 +1072,11 @@ _token_list_equal_ignoring_space (token_list_t *a, token_list_t *b)
* It need not be exactly the same amount of whitespace,
* though.
*/
- if (node_a->token->type == SPACE
- && node_b->token->type == SPACE) {
- while (node_a->token->type == SPACE)
+ if (node_a->token->type == SPACE_TOK
+ && node_b->token->type == SPACE_TOK) {
+ while (node_a->token->type == SPACE_TOK)
node_a = node_a->next;
- while (node_b->token->type == SPACE)
+ while (node_b->token->type == SPACE_TOK)
node_b = node_b->next;
continue;
}
@@ -1084,16 +1085,16 @@ _token_list_equal_ignoring_space (token_list_t *a, token_list_t *b)
return 0;
switch (node_a->token->type) {
- case INTEGER:
+ case INTEGER_TOK:
if (node_a->token->value.ival !=
node_b->token->value.ival)
{
return 0;
}
break;
- case IDENTIFIER:
- case INTEGER_STRING:
- case OTHER:
+ case IDENTIFIER_TOK:
+ case INTEGER_STRING_TOK:
+ case OTHER_TOK:
if (strcmp (node_a->token->value.str,
node_b->token->value.str))
{
@@ -1118,54 +1119,54 @@ _token_print (char **out, size_t *len, token_t *token)
}
switch (token->type) {
- case INTEGER:
+ case INTEGER_TOK:
ralloc_asprintf_rewrite_tail (out, len, "%" PRIiMAX, token->value.ival);
break;
- case IDENTIFIER:
- case INTEGER_STRING:
- case OTHER:
+ case IDENTIFIER_TOK:
+ case INTEGER_STRING_TOK:
+ case OTHER_TOK:
ralloc_asprintf_rewrite_tail (out, len, "%s", token->value.str);
break;
- case SPACE:
+ case SPACE_TOK:
ralloc_asprintf_rewrite_tail (out, len, " ");
break;
- case LEFT_SHIFT:
+ case LEFT_SHIFT_TOK:
ralloc_asprintf_rewrite_tail (out, len, "<<");
break;
- case RIGHT_SHIFT:
+ case RIGHT_SHIFT_TOK:
ralloc_asprintf_rewrite_tail (out, len, ">>");
break;
- case LESS_OR_EQUAL:
+ case LESS_OR_EQUAL_TOK:
ralloc_asprintf_rewrite_tail (out, len, "<=");
break;
- case GREATER_OR_EQUAL:
+ case GREATER_OR_EQUAL_TOK:
ralloc_asprintf_rewrite_tail (out, len, ">=");
break;
- case EQUAL:
+ case EQUAL_TOK:
ralloc_asprintf_rewrite_tail (out, len, "==");
break;
- case NOT_EQUAL:
+ case NOT_EQUAL_TOK:
ralloc_asprintf_rewrite_tail (out, len, "!=");
break;
- case AND:
+ case AND_TOK:
ralloc_asprintf_rewrite_tail (out, len, "&&");
break;
- case OR:
+ case OR_TOK:
ralloc_asprintf_rewrite_tail (out, len, "||");
break;
- case PASTE:
+ case PASTE_TOK:
ralloc_asprintf_rewrite_tail (out, len, "##");
break;
- case PLUS_PLUS:
+ case PLUS_PLUS_TOK:
ralloc_asprintf_rewrite_tail (out, len, "++");
break;
- case MINUS_MINUS:
+ case MINUS_MINUS_TOK:
ralloc_asprintf_rewrite_tail (out, len, "--");
break;
- case DEFINED:
+ case DEFINED_TOK:
ralloc_asprintf_rewrite_tail (out, len, "defined");
break;
- case PLACEHOLDER:
+ case PLACEHOLDER_TOK:
/* Nothing to print. */
break;
default:
@@ -1187,11 +1188,11 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
token_t *combined = NULL;
/* Pasting a placeholder onto anything makes no change. */
- if (other->type == PLACEHOLDER)
+ if (other->type == PLACEHOLDER_TOK)
return token;
/* When 'token' is a placeholder, just return 'other'. */
- if (token->type == PLACEHOLDER)
+ if (token->type == PLACEHOLDER_TOK)
return other;
/* A very few single-character punctuators can be combined
@@ -1199,31 +1200,31 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
switch (token->type) {
case '<':
if (other->type == '<')
- combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
+ combined = _token_create_ival (token, LEFT_SHIFT_TOK, LEFT_SHIFT_TOK);
else if (other->type == '=')
- combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
+ combined = _token_create_ival (token, LESS_OR_EQUAL_TOK, LESS_OR_EQUAL_TOK);
break;
case '>':
if (other->type == '>')
- combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
+ combined = _token_create_ival (token, RIGHT_SHIFT_TOK, RIGHT_SHIFT_TOK);
else if (other->type == '=')
- combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL);
+ combined = _token_create_ival (token, GREATER_OR_EQUAL_TOK, GREATER_OR_EQUAL_TOK);
break;
case '=':
if (other->type == '=')
- combined = _token_create_ival (token, EQUAL, EQUAL);
+ combined = _token_create_ival (token, EQUAL_TOK, EQUAL_TOK);
break;
case '!':
if (other->type == '=')
- combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
+ combined = _token_create_ival (token, NOT_EQUAL_TOK, NOT_EQUAL_TOK);
break;
case '&':
if (other->type == '&')
- combined = _token_create_ival (token, AND, AND);
+ combined = _token_create_ival (token, AND_TOK, AND_TOK);
break;
case '|':
if (other->type == '|')
- combined = _token_create_ival (token, OR, OR);
+ combined = _token_create_ival (token, OR_TOK, OR_TOK);
break;
}
@@ -1242,8 +1243,8 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
* the second token must also be an integer or must be a
* string representing an integer that begins with a digit.
*/
- if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING || token->type == INTEGER) &&
- (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING || other->type == INTEGER))
+ if ((token->type == IDENTIFIER_TOK || token->type == OTHER_TOK || token->type == INTEGER_STRING_TOK || token->type == INTEGER_TOK) &&
+ (other->type == IDENTIFIER_TOK || other->type == OTHER_TOK || other->type == INTEGER_STRING_TOK || other->type == INTEGER_TOK))
{
char *str;
int combined_type;
@@ -1251,15 +1252,15 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
/* Check that pasting onto an integer doesn't create a
* non-integer, (that is, only digits can be
* pasted. */
- if (token->type == INTEGER_STRING || token->type == INTEGER)
+ if (token->type == INTEGER_STRING_TOK || token->type == INTEGER_TOK)
{
switch (other->type) {
- case INTEGER_STRING:
+ case INTEGER_STRING_TOK:
if (other->value.str[0] < '0' ||
other->value.str[0] > '9')
goto FAIL;
break;
- case INTEGER:
+ case INTEGER_TOK:
if (other->value.ival < 0)
goto FAIL;
break;
@@ -1268,14 +1269,14 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
}
}
- if (token->type == INTEGER)
+ if (token->type == INTEGER_TOK)
str = ralloc_asprintf (token, "%" PRIiMAX,
token->value.ival);
else
str = ralloc_strdup (token, token->value.str);
- if (other->type == INTEGER)
+ if (other->type == INTEGER_TOK)
ralloc_asprintf_append (&str, "%" PRIiMAX,
other->value.ival);
else
@@ -1285,8 +1286,8 @@ _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
* started with an integer, in which case we will be
* creating an integer-string. */
combined_type = token->type;
- if (combined_type == INTEGER)
- combined_type = INTEGER_STRING;
+ if (combined_type == INTEGER_TOK)
+ combined_type = INTEGER_STRING_TOK;
combined = _token_create_str (token, combined_type, str);
combined->location = token->location;
@@ -1328,7 +1329,7 @@ static void add_builtin_define(glcpp_parser_t *parser,
token_t *tok;
token_list_t *list;
- tok = _token_create_ival (parser, INTEGER, value);
+ tok = _token_create_ival (parser, INTEGER_TOK, value);
list = _token_list_create(parser);
_token_list_append(list, tok);
@@ -1429,7 +1430,7 @@ _arguments_parse (argument_list_t *arguments,
node = node->next;
/* Ignore whitespace before first parenthesis. */
- while (node && node->token->type == SPACE)
+ while (node && node->token->type == SPACE_TOK)
node = node->next;
if (node == NULL || node->token->type != '(')
@@ -1463,7 +1464,7 @@ _arguments_parse (argument_list_t *arguments,
if (argument->head == NULL) {
/* Don't treat initial whitespace as
* part of the arguement. */
- if (node->token->type == SPACE)
+ if (node->token->type == SPACE_TOK)
continue;
}
_token_list_append (argument, node->token);
@@ -1494,23 +1495,23 @@ _token_list_create_with_one_ival (void *ctx, int type, int ival)
static token_list_t *
_token_list_create_with_one_space (void *ctx)
{
- return _token_list_create_with_one_ival (ctx, SPACE, SPACE);
+ return _token_list_create_with_one_ival (ctx, SPACE_TOK, SPACE_TOK);
}
static token_list_t *
_token_list_create_with_one_integer (void *ctx, int ival)
{
- return _token_list_create_with_one_ival (ctx, INTEGER, ival);
+ return _token_list_create_with_one_ival (ctx, INTEGER_TOK, ival);
}
-/* Evaluate a DEFINED token node (based on subsequent tokens in the list).
+/* Evaluate a DEFINED_TOK token node (based on subsequent tokens in the list).
*
- * Note: This function must only be called when "node" is a DEFINED token,
+ * Note: This function must only be called when "node" is a DEFINED_TOK token,
* (and will abort with an assertion failure otherwise).
*
- * If "node" is followed, (ignoring any SPACE tokens), by an IDENTIFIER token
- * (optionally preceded and followed by '(' and ')' tokens) then the following
- * occurs:
+ * If "node" is followed, (ignoring any SPACE tokens), by an IDENTIFIER_TOK
+ * token (optionally preceded and followed by '(' and ')' tokens) then the
+ * following occurs:
*
* If the identifier is a defined macro, this function returns 1.
*
@@ -1531,28 +1532,28 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser,
{
token_node_t *argument, *defined = node;
- assert (node->token->type == DEFINED);
+ assert (node->token->type == DEFINED_TOK);
node = node->next;
- /* Ignore whitespace after DEFINED token. */
- while (node && node->token->type == SPACE)
+ /* Ignore whitespace after DEFINED_TOK token. */
+ while (node && node->token->type == SPACE_TOK)
node = node->next;
if (node == NULL)
goto FAIL;
- if (node->token->type == IDENTIFIER || node->token->type == OTHER) {
+ if (node->token->type == IDENTIFIER_TOK || node->token->type == OTHER_TOK) {
argument = node;
} else if (node->token->type == '(') {
node = node->next;
/* Ignore whitespace after '(' token. */
- while (node && node->token->type == SPACE)
+ while (node && node->token->type == SPACE_TOK)
node = node->next;
- if (node == NULL || (node->token->type != IDENTIFIER &&
- node->token->type != OTHER))
+ if (node == NULL || (node->token->type != IDENTIFIER_TOK &&
+ node->token->type != OTHER_TOK))
{
goto FAIL;
}
@@ -1562,7 +1563,7 @@ _glcpp_parser_evaluate_defined (glcpp_parser_t *parser,
node = node->next;
/* Ignore whitespace after identifier, before ')' token. */
- while (node && node->token->type == SPACE)
+ while (node && node->token->type == SPACE_TOK)
node = node->next;
if (node == NULL || node->token->type != ')')
@@ -1599,7 +1600,7 @@ _glcpp_parser_evaluate_defined_in_list (glcpp_parser_t *parser,
while (node) {
- if (node->token->type != DEFINED)
+ if (node->token->type != DEFINED_TOK)
goto NEXT;
value = _glcpp_parser_evaluate_defined (parser, node, &last);
@@ -1607,7 +1608,7 @@ _glcpp_parser_evaluate_defined_in_list (glcpp_parser_t *parser,
goto NEXT;
replacement = ralloc (list, token_node_t);
- replacement->token = _token_create_ival (list, INTEGER, value);
+ replacement->token = _token_create_ival (list, INTEGER_TOK, value);
/* Splice replacement node into list, replacing from "node"
* through "last". */
@@ -1662,22 +1663,22 @@ _glcpp_parser_apply_pastes (glcpp_parser_t *parser, token_list_t *list)
{
token_node_t *next_non_space;
- /* Look ahead for a PASTE token, skipping space. */
+ /* Look ahead for a PASTE_TOK token, skipping space. */
next_non_space = node->next;
- while (next_non_space && next_non_space->token->type == SPACE)
+ while (next_non_space && next_non_space->token->type == SPACE_TOK)
next_non_space = next_non_space->next;
if (next_non_space == NULL)
break;
- if (next_non_space->token->type != PASTE) {
+ if (next_non_space->token->type != PASTE_TOK) {
node = next_non_space;
continue;
}
- /* Now find the next non-space token after the PASTE. */
+ /* Now find the next non-space token after the PASTE_TOK. */
next_non_space = next_non_space->next;
- while (next_non_space && next_non_space->token->type == SPACE)
+ while (next_non_space && next_non_space->token->type == SPACE_TOK)
next_non_space = next_non_space->next;
if (next_non_space == NULL) {
@@ -1771,7 +1772,7 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser,
for (node = macro->replacements->head; node; node = node->next)
{
- if (node->token->type == IDENTIFIER &&
+ if (node->token->type == IDENTIFIER_TOK &&
_string_list_contains (macro->parameters,
node->token->value.str,
¶meter_index))
@@ -1795,8 +1796,8 @@ _glcpp_parser_expand_function (glcpp_parser_t *parser,
token_t *new_token;
new_token = _token_create_ival (substituted,
- PLACEHOLDER,
- PLACEHOLDER);
+ PLACEHOLDER_TOK,
+ PLACEHOLDER_TOK);
_token_list_append (substituted, new_token);
}
} else {
@@ -1843,7 +1844,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser,
macro_t *macro;
/* We only expand identifiers */
- if (token->type != IDENTIFIER) {
+ if (token->type != IDENTIFIER_TOK) {
return NULL;
}
@@ -1868,15 +1869,15 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser,
/* Finally, don't expand this macro if we're already actively
* expanding it, (to avoid infinite recursion). */
if (_parser_active_list_contains (parser, identifier)) {
- /* We change the token type here from IDENTIFIER to
- * OTHER to prevent any future expansion of this
+ /* We change the token type here from IDENTIFIER_TOK to
+ * OTHER_TOK to prevent any future expansion of this
* unexpanded token. */
char *str;
token_list_t *expansion;
token_t *final;
str = ralloc_strdup (parser, token->value.str);
- final = _token_create_str (parser, OTHER, str);
+ final = _token_create_str (parser, OTHER_TOK, str);
expansion = _token_list_create (parser);
_token_list_append (expansion, final);
return expansion;
@@ -1886,7 +1887,7 @@ _glcpp_parser_expand_node (glcpp_parser_t *parser,
{
token_list_t *replacement;
- /* Replace a macro defined as empty with a SPACE token. */
+ /* Replace a macro defined as empty with a SPACE_TOK token. */
if (macro->replacements == NULL)
return _token_list_create_with_one_space (parser);
@@ -1956,21 +1957,21 @@ _parser_active_list_contains (glcpp_parser_t *parser, const char *identifier)
* nodes, continuing to expand as necessary. The results are placed in
* 'list' itself.
*
- * The "mode" argument controls the handling of any DEFINED tokens that
+ * The "mode" argument controls the handling of any DEFINED_TOK tokens that
* result from expansion as follows:
*
- * EXPANSION_MODE_IGNORE_DEFINED: Any resulting DEFINED tokens will be
+ * EXPANSION_MODE_IGNORE_DEFINED: Any resulting DEFINED_TOK tokens will be
* left in the final list, unevaluated. This is the correct mode
* for expanding any list in any context other than a
* preprocessor conditional, (#if or #elif).
*
- * EXPANSION_MODE_EVALUATE_DEFINED: Any resulting DEFINED tokens will be
- * evaluated to 0 or 1 tokens depending on whether the following
- * token is the name of a defined macro. If the DEFINED token is
- * not followed by an (optionally parenthesized) identifier, then
- * an error will be generated. This the correct mode for
- * expanding any list in the context of a preprocessor
- * conditional, (#if or #elif).
+ * EXPANSION_MODE_EVALUATE_DEFINED: Any resulting DEFINED_TOK tokens will
+ * be evaluated to 0 or 1 tokens depending on whether the
+ * following token is the name of a defined macro. If the
+ * DEFINED_TOK token is not followed by an (optionally
+ * parenthesized) identifier, then an error will be
+ * generated. This the correct mode for expanding any list in the
+ * context of a preprocessor conditional, (#if or #elif).
*/
static void
_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
@@ -2197,10 +2198,10 @@ glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
ret = glcpp_lex (yylval, yylloc, parser->scanner);
/* XXX: This ugly block of code exists for the sole
- * purpose of converting a NEWLINE token into a SPACE
- * token, but only in the case where we have seen a
- * function-like macro name, but have not yet seen its
- * closing parenthesis.
+ * purpose of converting a NEWLINE_TOK token into a
+ * SPACE_TOK token, but only in the case where we have
+ * seen a function-like macro name, but have not yet
+ * seen its closing parenthesis.
*
* There's perhaps a more compact way to do this with
* mid-rule actions in the grammar.
@@ -2216,27 +2217,27 @@ glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
parser->paren_count--;
if (parser->paren_count == 0)
parser->newline_as_space = 0;
- } else if (ret == NEWLINE) {
- ret = SPACE;
- } else if (ret != SPACE) {
+ } else if (ret == NEWLINE_TOK) {
+ ret = SPACE_TOK;
+ } else if (ret != SPACE_TOK) {
if (parser->paren_count == 0)
parser->newline_as_space = 0;
}
}
else if (parser->in_control_line)
{
- if (ret == NEWLINE)
+ if (ret == NEWLINE_TOK)
parser->in_control_line = 0;
}
- else if (ret == DEFINE_TOKEN ||
- ret == UNDEF || ret == IF ||
- ret == IFDEF || ret == IFNDEF ||
- ret == ELIF || ret == ELSE ||
- ret == ENDIF || ret == HASH_TOKEN)
+ else if (ret == DEFINE_TOK ||
+ ret == UNDEF_TOK || ret == IF_TOK ||
+ ret == IFDEF_TOK || ret == IFNDEF_TOK ||
+ ret == ELIF_TOK || ret == ELSE_TOK ||
+ ret == ENDIF_TOK || ret == HASH_TOK)
{
parser->in_control_line = 1;
}
- else if (ret == IDENTIFIER)
+ else if (ret == IDENTIFIER_TOK)
{
macro_t *macro;
macro = hash_table_find (parser->defines,
@@ -2255,7 +2256,7 @@ glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
if (node == NULL) {
ralloc_free (parser->lex_from_list);
parser->lex_from_list = NULL;
- return NEWLINE;
+ return NEWLINE_TOK;
}
*yylval = node->token->value;
@@ -2277,7 +2278,7 @@ glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
parser->lex_from_list = _token_list_create (parser);
for (node = list->head; node; node = node->next) {
- if (node->token->type == SPACE)
+ if (node->token->type == SPACE_TOK)
continue;
_token_list_append (parser->lex_from_list, node->token);
}
diff --git a/src/glsl/glcpp/tests/102-garbage-after-endif.c.expected b/src/glsl/glcpp/tests/102-garbage-after-endif.c.expected
index d9f3bdc..5132d7c 100644
--- a/src/glsl/glcpp/tests/102-garbage-after-endif.c.expected
+++ b/src/glsl/glcpp/tests/102-garbage-after-endif.c.expected
@@ -1,2 +1,2 @@
-0:2(8): preprocessor error: syntax error, unexpected IDENTIFIER, expecting NEWLINE
+0:2(8): preprocessor error: syntax error, unexpected IDENTIFIER_TOK, expecting NEWLINE_TOK
diff --git a/src/glsl/glcpp/tests/103-garbage-after-else-0.c.expected b/src/glsl/glcpp/tests/103-garbage-after-else-0.c.expected
index b053b39..3f991b7 100644
--- a/src/glsl/glcpp/tests/103-garbage-after-else-0.c.expected
+++ b/src/glsl/glcpp/tests/103-garbage-after-else-0.c.expected
@@ -1,4 +1,4 @@
-0:2(7): preprocessor error: syntax error, unexpected IDENTIFIER, expecting NEWLINE
+0:2(7): preprocessor error: syntax error, unexpected IDENTIFIER_TOK, expecting NEWLINE_TOK
0:1(6): preprocessor error: Unterminated #if
diff --git a/src/glsl/glcpp/tests/123-garbage-after-else-1.c.expected b/src/glsl/glcpp/tests/123-garbage-after-else-1.c.expected
index b053b39..3f991b7 100644
--- a/src/glsl/glcpp/tests/123-garbage-after-else-1.c.expected
+++ b/src/glsl/glcpp/tests/123-garbage-after-else-1.c.expected
@@ -1,4 +1,4 @@
-0:2(7): preprocessor error: syntax error, unexpected IDENTIFIER, expecting NEWLINE
+0:2(7): preprocessor error: syntax error, unexpected IDENTIFIER_TOK, expecting NEWLINE_TOK
0:1(6): preprocessor error: Unterminated #if
diff --git a/src/glsl/glcpp/tests/129-define-non-identifier.c.expected b/src/glsl/glcpp/tests/129-define-non-identifier.c.expected
index fd0b413..4c8df24 100644
--- a/src/glsl/glcpp/tests/129-define-non-identifier.c.expected
+++ b/src/glsl/glcpp/tests/129-define-non-identifier.c.expected
@@ -1,2 +1,2 @@
0:1(9): preprocessor error: #define followed by a non-identifier: 123
-0:1(9): preprocessor error: syntax error, unexpected INTEGER_STRING, expecting FUNC_IDENTIFIER or OBJ_IDENTIFIER
+0:1(9): preprocessor error: syntax error, unexpected INTEGER_STRING_TOK, expecting FUNC_IDENTIFIER_TOK or OBJ_IDENTIFIER_TOK
diff --git a/src/glsl/glcpp/tests/136-plus-plus-and-minus-minus.c.expected b/src/glsl/glcpp/tests/136-plus-plus-and-minus-minus.c.expected
index 137921b..d4bac54 100644
--- a/src/glsl/glcpp/tests/136-plus-plus-and-minus-minus.c.expected
+++ b/src/glsl/glcpp/tests/136-plus-plus-and-minus-minus.c.expected
@@ -1,4 +1,4 @@
-0:7(12): preprocessor error: syntax error, unexpected PLUS_PLUS
+0:7(12): preprocessor error: syntax error, unexpected PLUS_PLUS_TOK
a = x++;
b = ++x;
--
2.0.0
More information about the mesa-dev
mailing list