static int string_input(char* buf, int max_size, yyscan_t yyscanner);
static int check_type(yyscan_t yyscanner);
static int reserved_word(yyscan_t yyscanner);
+static int ES2_reserved_ES3_keyword(TParseContext *context, int token);
+static int ES2_keyword_ES3_reserved(TParseContext *context, int token);
%}
%option noyywrap nounput never-interactive
"lowp" { return(LOW_PRECISION); }
"precision" { return(PRECISION); }
-"attribute" { if (context->shaderVersion < 300) return(ATTRIBUTE); return reserved_word(yyscanner); }
+"attribute" { return ES2_keyword_ES3_reserved(context, ATTRIBUTE); }
"const" { return(CONST_QUAL); }
"uniform" { return(UNIFORM); }
-"varying" { if (context->shaderVersion < 300) return(VARYING); return reserved_word(yyscanner); }
+"varying" { return ES2_keyword_ES3_reserved(context, VARYING); }
"break" { return(BREAK); }
"continue" { return(CONTINUE); }
"if" { return(IF); }
"else" { return(ELSE); }
-"switch" { if (context->shaderVersion < 300) return reserved_word(yyscanner); return(SWITCH); }
-"case" { if (context->shaderVersion < 300) return reserved_word(yyscanner); return(CASE); }
-"default" { if (context->shaderVersion < 300) return reserved_word(yyscanner); return(DEFAULT); }
+"switch" { return ES2_reserved_ES3_keyword(context, SWITCH); }
+"case" { return ES2_reserved_ES3_keyword(context, CASE); }
+"default" { return ES2_reserved_ES3_keyword(context, DEFAULT); }
-"centroid" { if (context->shaderVersion < 300) return reserved_word(yyscanner); return(CENTROID); }
-"flat" { if (context->shaderVersion < 300) return reserved_word(yyscanner); return(FLAT); }
-"smooth" { if (context->shaderVersion < 300) return reserved_word(yyscanner); return(SMOOTH); }
+"centroid" { return ES2_reserved_ES3_keyword(context, CENTROID); }
+"flat" { return ES2_reserved_ES3_keyword(context, FLAT); }
+"smooth" { return ES2_reserved_ES3_keyword(context, SMOOTH); }
"in" { return(IN_QUAL); }
"out" { return(OUT_QUAL); }
"samplerCube" { context->lexAfterType = true; return SAMPLERCUBE; }
"samplerExternalOES" { context->lexAfterType = true; return SAMPLER_EXTERNAL_OES; }
"sampler3D" { context->lexAfterType = true; return SAMPLER3D; }
-"sampler3DRect" { if (context->shaderVersion < 300) return reserved_word(yyscanner); context->lexAfterType = true; return SAMPLER3DRECT; }
-"sampler2DShadow" { if (context->shaderVersion < 300) return reserved_word(yyscanner); context->lexAfterType = true; return SAMPLER2DSHADOW; }
+"sampler3DRect" { return ES2_reserved_ES3_keyword(context, SAMPLER3DRECT); }
+"sampler2DShadow" { return ES2_reserved_ES3_keyword(context, SAMPLER2DSHADOW); }
"struct" { context->lexAfterType = true; return(STRUCT); }
return 0;
}
+int ES2_reserved_ES3_keyword(TParseContext *context, int token)
+{
+ yyscan_t yyscanner = (yyscan_t) context->scanner;
+
+ if (context->shaderVersion < 300)
+ {
+ return reserved_word(yyscanner);
+ }
+
+ return token;
+}
+
+int ES2_keyword_ES3_reserved(TParseContext *context, int token)
+{
+ yyscan_t yyscanner = (yyscan_t) context->scanner;
+
+ if (context->shaderVersion >= 300)
+ {
+ return reserved_word(yyscanner);
+ }
+
+ return token;
+}
+
void yyerror(TParseContext* context, const char* reason) {
struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;
static int string_input(char* buf, int max_size, yyscan_t yyscanner);
static int check_type(yyscan_t yyscanner);
static int reserved_word(yyscan_t yyscanner);
+static int ES2_reserved_ES3_keyword(TParseContext *context, int token);
+static int ES2_keyword_ES3_reserved(TParseContext *context, int token);
#define INITIAL 0
#define COMMENT 1
YY_BREAK
case 11:
YY_RULE_SETUP
-{ if (context->shaderVersion < 300) return(ATTRIBUTE); return reserved_word(yyscanner); }
+{ return ES2_keyword_ES3_reserved(context, ATTRIBUTE); }
YY_BREAK
case 12:
YY_RULE_SETUP
YY_BREAK
case 14:
YY_RULE_SETUP
-{ if (context->shaderVersion < 300) return(VARYING); return reserved_word(yyscanner); }
+{ return ES2_keyword_ES3_reserved(context, VARYING); }
YY_BREAK
case 15:
YY_RULE_SETUP
YY_BREAK
case 22:
YY_RULE_SETUP
-{ if (context->shaderVersion < 300) return reserved_word(yyscanner); return(SWITCH); }
+{ return ES2_reserved_ES3_keyword(context, SWITCH); }
YY_BREAK
case 23:
YY_RULE_SETUP
-{ if (context->shaderVersion < 300) return reserved_word(yyscanner); return(CASE); }
+{ return ES2_reserved_ES3_keyword(context, CASE); }
YY_BREAK
case 24:
YY_RULE_SETUP
-{ if (context->shaderVersion < 300) return reserved_word(yyscanner); return(DEFAULT); }
+{ return ES2_reserved_ES3_keyword(context, DEFAULT); }
YY_BREAK
case 25:
YY_RULE_SETUP
-{ if (context->shaderVersion < 300) return reserved_word(yyscanner); return(CENTROID); }
+{ return ES2_reserved_ES3_keyword(context, CENTROID); }
YY_BREAK
case 26:
YY_RULE_SETUP
-{ if (context->shaderVersion < 300) return reserved_word(yyscanner); return(FLAT); }
+{ return ES2_reserved_ES3_keyword(context, FLAT); }
YY_BREAK
case 27:
YY_RULE_SETUP
-{ if (context->shaderVersion < 300) return reserved_word(yyscanner); return(SMOOTH); }
+{ return ES2_reserved_ES3_keyword(context, SMOOTH); }
YY_BREAK
case 28:
YY_RULE_SETUP
YY_BREAK
case 55:
YY_RULE_SETUP
-{ if (context->shaderVersion < 300) return reserved_word(yyscanner); context->lexAfterType = true; return SAMPLER3DRECT; }
+{ return ES2_reserved_ES3_keyword(context, SAMPLER3DRECT); }
YY_BREAK
case 56:
YY_RULE_SETUP
-{ if (context->shaderVersion < 300) return reserved_word(yyscanner); context->lexAfterType = true; return SAMPLER2DSHADOW; }
+{ return ES2_reserved_ES3_keyword(context, SAMPLER2DSHADOW); }
YY_BREAK
case 57:
YY_RULE_SETUP
return 0;
}
+int ES2_reserved_ES3_keyword(TParseContext *context, int token)
+{
+ yyscan_t yyscanner = (yyscan_t) context->scanner;
+
+ if (context->shaderVersion < 300)
+ {
+ return reserved_word(yyscanner);
+ }
+
+ return token;
+}
+
+int ES2_keyword_ES3_reserved(TParseContext *context, int token)
+{
+ yyscan_t yyscanner = (yyscan_t) context->scanner;
+
+ if (context->shaderVersion >= 300)
+ {
+ return reserved_word(yyscanner);
+ }
+
+ return token;
+}
+
void yyerror(TParseContext* context, const char* reason) {
struct yyguts_t* yyg = (struct yyguts_t*) context->scanner;