Allow future keywords to be accessed as members in a struct.

This fixes a bug where a token that could be a keyword in one version
is not a keyword in another version, but treated like a non-member after
a "." dereference.
This commit is contained in:
John Kessenich 2015-10-02 15:01:53 -06:00
parent 6373574b13
commit eb505e4262
7 changed files with 41 additions and 12 deletions

View file

@ -2,5 +2,5 @@
// For the version, it uses the latest git tag followed by the number of commits.
// For the date, it uses the current date (when then script is run).
#define GLSLANG_REVISION "3.0.777"
#define GLSLANG_DATE "01-Oct-2015"
#define GLSLANG_REVISION "3.0.778"
#define GLSLANG_DATE "02-Oct-2015"

View file

@ -598,7 +598,12 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token)
case PpAtomConstUint: parserToken->sType.lex.i = ppToken.ival; return UINTCONSTANT;
case PpAtomConstFloat: parserToken->sType.lex.d = ppToken.dval; return FLOATCONSTANT;
case PpAtomConstDouble: parserToken->sType.lex.d = ppToken.dval; return DOUBLECONSTANT;
case PpAtomIdentifier: return tokenizeIdentifier();
case PpAtomIdentifier:
{
int token = tokenizeIdentifier();
field = false;
return token;
}
case EndOfInput: return 0;
@ -623,7 +628,6 @@ int TScanContext::tokenizeIdentifier()
return identifierOrType();
}
keyword = it->second;
field = false;
switch (keyword) {
case CONST:
@ -1020,11 +1024,8 @@ int TScanContext::tokenizeIdentifier()
int TScanContext::identifierOrType()
{
parserToken->sType.lex.string = NewPoolTString(tokenText);
if (field) {
field = false;
return FIELD_SELECTION;
}
if (field)
return IDENTIFIER;
parserToken->sType.lex.symbol = parseContext.symbolTable.find(*parserToken->sType.lex.string);
if (afterType == false && parserToken->sType.lex.symbol) {

View file

@ -162,7 +162,6 @@ extern int yylex(YYSTYPE*, TParseContext&);
%token <lex> IDENTIFIER TYPE_NAME
%token <lex> FLOATCONSTANT DOUBLECONSTANT INTCONSTANT UINTCONSTANT BOOLCONSTANT
%token <lex> FIELD_SELECTION
%token <lex> LEFT_OP RIGHT_OP
%token <lex> INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP
%token <lex> AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN
@ -266,7 +265,7 @@ postfix_expression
| function_call {
$$ = $1;
}
| postfix_expression DOT FIELD_SELECTION {
| postfix_expression DOT IDENTIFIER {
$$ = parseContext.handleDotDereference($3.loc, $1, *$3.string);
}
| postfix_expression INC_OP {