ARB prog parser: Differentiate between used and unused names in the lexer
The lexer will return IDENTIFIER only when the name does not have an associated symbol. Otherwise USED_IDENTIFIER is returned.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -39,8 +39,7 @@
|
|||||||
if (condition) { \
|
if (condition) { \
|
||||||
return token; \
|
return token; \
|
||||||
} else { \
|
} else { \
|
||||||
yylval->string = strdup(yytext); \
|
return handle_ident(yyextra, yytext, yylval); \
|
||||||
return IDENTIFIER; \
|
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -64,8 +63,7 @@
|
|||||||
yylval->temp_inst.Opcode = OPCODE_ ## opcode; \
|
yylval->temp_inst.Opcode = OPCODE_ ## opcode; \
|
||||||
return token; \
|
return token; \
|
||||||
} else { \
|
} else { \
|
||||||
yylval->string = strdup(yytext); \
|
return handle_ident(yyextra, yytext, yylval); \
|
||||||
return IDENTIFIER; \
|
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@@ -114,6 +112,15 @@ swiz_from_char(char c)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
handle_ident(struct asm_parser_state *state, const char *text, YYSTYPE *lval)
|
||||||
|
{
|
||||||
|
lval->string = strdup(text);
|
||||||
|
|
||||||
|
return (_mesa_symbol_table_find_symbol(state->st, 0, text) == NULL)
|
||||||
|
? IDENTIFIER : USED_IDENTIFIER;
|
||||||
|
}
|
||||||
|
|
||||||
#define YY_USER_ACTION \
|
#define YY_USER_ACTION \
|
||||||
do { \
|
do { \
|
||||||
yylloc->first_column = yylloc->last_column; \
|
yylloc->first_column = yylloc->last_column; \
|
||||||
@@ -299,10 +306,7 @@ ARRAY2D { return_token_or_IDENTIFIER(require_ARB_fp && require
|
|||||||
ARRAYSHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); }
|
ARRAYSHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); }
|
||||||
ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); }
|
ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); }
|
||||||
|
|
||||||
[_a-zA-Z$][_a-zA-Z0-9$]* {
|
[_a-zA-Z$][_a-zA-Z0-9$]* { return handle_ident(yyextra, yytext, yylval); }
|
||||||
yylval->string = strdup(yytext);
|
|
||||||
return IDENTIFIER;
|
|
||||||
}
|
|
||||||
|
|
||||||
".." { return DOT_DOT; }
|
".." { return DOT_DOT; }
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -136,13 +136,14 @@
|
|||||||
VTXATTRIB = 352,
|
VTXATTRIB = 352,
|
||||||
WEIGHT = 353,
|
WEIGHT = 353,
|
||||||
IDENTIFIER = 354,
|
IDENTIFIER = 354,
|
||||||
MASK4 = 355,
|
USED_IDENTIFIER = 355,
|
||||||
MASK3 = 356,
|
MASK4 = 356,
|
||||||
MASK2 = 357,
|
MASK3 = 357,
|
||||||
MASK1 = 358,
|
MASK2 = 358,
|
||||||
SWIZZLE = 359,
|
MASK1 = 359,
|
||||||
DOT_DOT = 360,
|
SWIZZLE = 360,
|
||||||
DOT = 361
|
DOT_DOT = 361,
|
||||||
|
DOT = 362
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -182,7 +183,7 @@ typedef union YYSTYPE
|
|||||||
|
|
||||||
|
|
||||||
/* Line 1676 of yacc.c */
|
/* Line 1676 of yacc.c */
|
||||||
#line 186 "program_parse.tab.h"
|
#line 187 "program_parse.tab.h"
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
# define YYSTYPE_IS_TRIVIAL 1
|
# define YYSTYPE_IS_TRIVIAL 1
|
||||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||||
|
@@ -178,7 +178,8 @@ static struct asm_instruction *asm_instruction_copy_ctor(
|
|||||||
%token VERTEX VTXATTRIB
|
%token VERTEX VTXATTRIB
|
||||||
%token WEIGHT
|
%token WEIGHT
|
||||||
|
|
||||||
%token <string> IDENTIFIER
|
%token <string> IDENTIFIER USED_IDENTIFIER
|
||||||
|
%type <string> string
|
||||||
%token <swiz_mask> MASK4 MASK3 MASK2 MASK1 SWIZZLE
|
%token <swiz_mask> MASK4 MASK3 MASK2 MASK1 SWIZZLE
|
||||||
%token DOT_DOT
|
%token DOT_DOT
|
||||||
%token DOT
|
%token DOT
|
||||||
@@ -289,7 +290,7 @@ optionSequence: optionSequence option
|
|||||||
|
|
|
|
||||||
;
|
;
|
||||||
|
|
||||||
option: OPTION IDENTIFIER ';'
|
option: OPTION string ';'
|
||||||
{
|
{
|
||||||
int valid = 0;
|
int valid = 0;
|
||||||
|
|
||||||
@@ -692,7 +693,7 @@ extSwizSel: INTEGER
|
|||||||
$$.xyzw_valid = 1;
|
$$.xyzw_valid = 1;
|
||||||
$$.rgba_valid = 1;
|
$$.rgba_valid = 1;
|
||||||
}
|
}
|
||||||
| IDENTIFIER
|
| string
|
||||||
{
|
{
|
||||||
if (strlen($1) > 1) {
|
if (strlen($1) > 1) {
|
||||||
yyerror(& @1, state, "invalid extended swizzle selector");
|
yyerror(& @1, state, "invalid extended swizzle selector");
|
||||||
@@ -742,7 +743,7 @@ extSwizSel: INTEGER
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
srcReg: IDENTIFIER /* temporaryReg | progParamSingle */
|
srcReg: USED_IDENTIFIER /* temporaryReg | progParamSingle */
|
||||||
{
|
{
|
||||||
struct asm_symbol *const s = (struct asm_symbol *)
|
struct asm_symbol *const s = (struct asm_symbol *)
|
||||||
_mesa_symbol_table_find_symbol(state->st, 0, $1);
|
_mesa_symbol_table_find_symbol(state->st, 0, $1);
|
||||||
@@ -832,7 +833,7 @@ dstReg: resultBinding
|
|||||||
$$.File = PROGRAM_OUTPUT;
|
$$.File = PROGRAM_OUTPUT;
|
||||||
$$.Index = $1;
|
$$.Index = $1;
|
||||||
}
|
}
|
||||||
| IDENTIFIER /* temporaryReg | vertexResultReg */
|
| USED_IDENTIFIER /* temporaryReg | vertexResultReg */
|
||||||
{
|
{
|
||||||
struct asm_symbol *const s = (struct asm_symbol *)
|
struct asm_symbol *const s = (struct asm_symbol *)
|
||||||
_mesa_symbol_table_find_symbol(state->st, 0, $1);
|
_mesa_symbol_table_find_symbol(state->st, 0, $1);
|
||||||
@@ -863,7 +864,7 @@ dstReg: resultBinding
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
progParamArray: IDENTIFIER
|
progParamArray: USED_IDENTIFIER
|
||||||
{
|
{
|
||||||
struct asm_symbol *const s = (struct asm_symbol *)
|
struct asm_symbol *const s = (struct asm_symbol *)
|
||||||
_mesa_symbol_table_find_symbol(state->st, 0, $1);
|
_mesa_symbol_table_find_symbol(state->st, 0, $1);
|
||||||
@@ -930,7 +931,7 @@ addrRegNegOffset: INTEGER
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
addrReg: IDENTIFIER
|
addrReg: USED_IDENTIFIER
|
||||||
{
|
{
|
||||||
struct asm_symbol *const s = (struct asm_symbol *)
|
struct asm_symbol *const s = (struct asm_symbol *)
|
||||||
_mesa_symbol_table_find_symbol(state->st, 0, $1);
|
_mesa_symbol_table_find_symbol(state->st, 0, $1);
|
||||||
@@ -1814,7 +1815,7 @@ optionalSign: '+' { $$ = FALSE; }
|
|||||||
TEMP_statement: optVarSize TEMP { $<integer>$ = $2; } varNameList
|
TEMP_statement: optVarSize TEMP { $<integer>$ = $2; } varNameList
|
||||||
;
|
;
|
||||||
|
|
||||||
optVarSize: IDENTIFIER
|
optVarSize: string
|
||||||
{
|
{
|
||||||
/* NV_fragment_program_option defines the size qualifiers in a
|
/* NV_fragment_program_option defines the size qualifiers in a
|
||||||
* fairly broken way. "SHORT" or "LONG" can optionally be used
|
* fairly broken way. "SHORT" or "LONG" can optionally be used
|
||||||
@@ -2045,7 +2046,7 @@ legacyTexUnitNum: INTEGER
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
ALIAS_statement: ALIAS IDENTIFIER '=' IDENTIFIER
|
ALIAS_statement: ALIAS IDENTIFIER '=' USED_IDENTIFIER
|
||||||
{
|
{
|
||||||
struct asm_symbol *exist = (struct asm_symbol *)
|
struct asm_symbol *exist = (struct asm_symbol *)
|
||||||
_mesa_symbol_table_find_symbol(state->st, 0, $2);
|
_mesa_symbol_table_find_symbol(state->st, 0, $2);
|
||||||
@@ -2066,6 +2067,10 @@ ALIAS_statement: ALIAS IDENTIFIER '=' IDENTIFIER
|
|||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
string: IDENTIFIER
|
||||||
|
| USED_IDENTIFIER
|
||||||
|
;
|
||||||
|
|
||||||
%%
|
%%
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user