2010-02-22 13:19:34 -08:00
|
|
|
%{
|
|
|
|
/*
|
|
|
|
* Copyright © 2008, 2009 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
2010-04-26 14:19:49 -07:00
|
|
|
#include <ctype.h>
|
2011-10-03 16:59:01 -07:00
|
|
|
#include <limits.h>
|
2010-12-13 08:41:08 -07:00
|
|
|
#include "strtod.h"
|
2010-02-22 13:19:34 -08:00
|
|
|
#include "ast.h"
|
|
|
|
#include "glsl_parser_extras.h"
|
2010-02-25 17:17:23 -08:00
|
|
|
#include "glsl_parser.h"
|
2010-02-22 13:19:34 -08:00
|
|
|
|
2011-01-27 17:52:19 -08:00
|
|
|
static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
|
|
|
|
|
2011-03-04 12:49:55 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#define YY_NO_UNISTD_H
|
|
|
|
#endif
|
|
|
|
|
2010-02-22 13:19:34 -08:00
|
|
|
#define YY_USER_ACTION \
|
|
|
|
do { \
|
|
|
|
yylloc->source = 0; \
|
|
|
|
yylloc->first_column = yycolumn + 1; \
|
|
|
|
yylloc->first_line = yylineno + 1; \
|
|
|
|
yycolumn += yyleng; \
|
|
|
|
} while(0);
|
|
|
|
|
2010-07-07 11:40:51 -07:00
|
|
|
#define YY_USER_INIT yylineno = 0; yycolumn = 0;
|
|
|
|
|
2010-11-13 20:32:59 -08:00
|
|
|
/* A macro for handling reserved words and keywords across language versions.
|
|
|
|
*
|
|
|
|
* Certain words start out as identifiers, become reserved words in
|
|
|
|
* later language revisions, and finally become language keywords.
|
2012-08-01 19:04:59 -07:00
|
|
|
* This may happen at different times in desktop GLSL and GLSL ES.
|
2010-11-13 20:32:59 -08:00
|
|
|
*
|
|
|
|
* For example, consider the following lexer rule:
|
2012-08-01 19:04:59 -07:00
|
|
|
* samplerBuffer KEYWORD(130, 0, 140, 0, SAMPLERBUFFER)
|
2010-11-13 20:32:59 -08:00
|
|
|
*
|
|
|
|
* This means that "samplerBuffer" will be treated as:
|
|
|
|
* - a keyword (SAMPLERBUFFER token) ...in GLSL >= 1.40
|
|
|
|
* - a reserved word - error ...in GLSL >= 1.30
|
2012-08-01 19:04:59 -07:00
|
|
|
* - an identifier ...in GLSL < 1.30 or GLSL ES
|
2010-11-13 20:32:59 -08:00
|
|
|
*/
|
2012-08-01 19:04:59 -07:00
|
|
|
#define KEYWORD(reserved_glsl, reserved_glsl_es, \
|
|
|
|
allowed_glsl, allowed_glsl_es, token) \
|
|
|
|
KEYWORD_WITH_ALT(reserved_glsl, reserved_glsl_es, \
|
|
|
|
allowed_glsl, allowed_glsl_es, false, token)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Like the KEYWORD macro, but the word is also treated as a keyword
|
|
|
|
* if the given boolean expression is true.
|
|
|
|
*/
|
|
|
|
#define KEYWORD_WITH_ALT(reserved_glsl, reserved_glsl_es, \
|
|
|
|
allowed_glsl, allowed_glsl_es, \
|
|
|
|
alt_expr, token) \
|
2010-08-11 17:01:31 -07:00
|
|
|
do { \
|
2012-08-01 19:04:59 -07:00
|
|
|
if (yyextra->is_version(allowed_glsl, allowed_glsl_es) \
|
2013-07-11 10:11:18 -07:00
|
|
|
|| (alt_expr)) { \
|
2010-08-11 17:01:31 -07:00
|
|
|
return token; \
|
2012-08-01 19:04:59 -07:00
|
|
|
} else if (yyextra->is_version(reserved_glsl, \
|
|
|
|
reserved_glsl_es)) { \
|
2010-08-11 17:01:31 -07:00
|
|
|
_mesa_glsl_error(yylloc, yyextra, \
|
|
|
|
"Illegal use of reserved word `%s'", yytext); \
|
|
|
|
return ERROR_TOK; \
|
2010-11-13 20:32:59 -08:00
|
|
|
} else { \
|
|
|
|
yylval->identifier = strdup(yytext); \
|
2011-01-27 17:52:19 -08:00
|
|
|
return classify_identifier(yyextra, yytext); \
|
2010-08-11 17:01:31 -07:00
|
|
|
} \
|
|
|
|
} while (0)
|
2010-11-13 20:32:59 -08:00
|
|
|
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
/**
|
|
|
|
* A macro for handling keywords that have been present in GLSL since
|
|
|
|
* its origin, but were changed into reserved words in GLSL 3.00 ES.
|
|
|
|
*/
|
|
|
|
#define DEPRECATED_ES_KEYWORD(token) \
|
|
|
|
do { \
|
|
|
|
if (yyextra->is_version(0, 300)) { \
|
|
|
|
_mesa_glsl_error(yylloc, yyextra, \
|
|
|
|
"Illegal use of reserved word `%s'", yytext); \
|
|
|
|
return ERROR_TOK; \
|
|
|
|
} else { \
|
|
|
|
return token; \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2011-10-03 16:59:01 -07:00
|
|
|
static int
|
|
|
|
literal_integer(char *text, int len, struct _mesa_glsl_parse_state *state,
|
|
|
|
YYSTYPE *lval, YYLTYPE *lloc, int base)
|
|
|
|
{
|
|
|
|
bool is_uint = (text[len - 1] == 'u' ||
|
|
|
|
text[len - 1] == 'U');
|
|
|
|
const char *digits = text;
|
|
|
|
|
|
|
|
/* Skip "0x" */
|
|
|
|
if (base == 16)
|
|
|
|
digits += 2;
|
|
|
|
|
2011-10-29 10:37:58 -07:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
unsigned __int64 value = _strtoui64(digits, NULL, base);
|
|
|
|
#else
|
2011-10-03 16:59:01 -07:00
|
|
|
unsigned long long value = strtoull(digits, NULL, base);
|
2011-10-29 10:37:58 -07:00
|
|
|
#endif
|
2011-10-03 16:59:01 -07:00
|
|
|
|
|
|
|
lval->n = (int)value;
|
|
|
|
|
|
|
|
if (value > UINT_MAX) {
|
|
|
|
/* Note that signed 0xffffffff is valid, not out of range! */
|
2012-08-02 08:18:12 -07:00
|
|
|
if (state->is_version(130, 300)) {
|
2011-10-03 16:59:01 -07:00
|
|
|
_mesa_glsl_error(lloc, state,
|
|
|
|
"Literal value `%s' out of range", text);
|
|
|
|
} else {
|
|
|
|
_mesa_glsl_warning(lloc, state,
|
|
|
|
"Literal value `%s' out of range", text);
|
|
|
|
}
|
|
|
|
} else if (base == 10 && !is_uint && (unsigned)value > (unsigned)INT_MAX + 1) {
|
|
|
|
/* Tries to catch unintentionally providing a negative value.
|
|
|
|
* Note that -2147483648 is parsed as -(2147483648), so we don't
|
|
|
|
* want to warn for INT_MAX.
|
|
|
|
*/
|
|
|
|
_mesa_glsl_warning(lloc, state,
|
|
|
|
"Signed literal value `%s' is interpreted as %d",
|
|
|
|
text, lval->n);
|
|
|
|
}
|
|
|
|
return is_uint ? UINTCONSTANT : INTCONSTANT;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define LITERAL_INTEGER(base) \
|
|
|
|
literal_integer(yytext, yyleng, yyextra, yylval, yylloc, base)
|
|
|
|
|
2010-02-22 13:19:34 -08:00
|
|
|
%}
|
|
|
|
|
|
|
|
%option bison-bridge bison-locations reentrant noyywrap
|
2010-04-29 17:53:26 -07:00
|
|
|
%option nounput noyy_top_state
|
2010-02-22 13:19:34 -08:00
|
|
|
%option never-interactive
|
|
|
|
%option prefix="_mesa_glsl_"
|
|
|
|
%option extra-type="struct _mesa_glsl_parse_state *"
|
|
|
|
|
2010-08-30 11:58:04 -07:00
|
|
|
%x PP PRAGMA
|
2010-02-22 13:19:34 -08:00
|
|
|
|
2010-04-26 14:19:49 -07:00
|
|
|
DEC_INT [1-9][0-9]*
|
|
|
|
HEX_INT 0[xX][0-9a-fA-F]+
|
|
|
|
OCT_INT 0[0-7]*
|
|
|
|
INT ({DEC_INT}|{HEX_INT}|{OCT_INT})
|
|
|
|
SPC [ \t]*
|
|
|
|
SPCP [ \t]+
|
|
|
|
HASH ^{SPC}#{SPC}
|
2010-02-22 13:19:34 -08:00
|
|
|
%%
|
|
|
|
|
|
|
|
[ \r\t]+ ;
|
|
|
|
|
|
|
|
/* Preprocessor tokens. */
|
|
|
|
^[ \t]*#[ \t]*$ ;
|
2011-12-23 19:21:05 -05:00
|
|
|
^[ \t]*#[ \t]*version { BEGIN PP; return VERSION_TOK; }
|
2010-02-22 13:19:34 -08:00
|
|
|
^[ \t]*#[ \t]*extension { BEGIN PP; return EXTENSION; }
|
2010-04-26 14:19:49 -07:00
|
|
|
{HASH}line{SPCP}{INT}{SPCP}{INT}{SPC}$ {
|
|
|
|
/* Eat characters until the first digit is
|
|
|
|
* encountered
|
|
|
|
*/
|
|
|
|
char *ptr = yytext;
|
|
|
|
while (!isdigit(*ptr))
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
/* Subtract one from the line number because
|
|
|
|
* yylineno is zero-based instead of
|
|
|
|
* one-based.
|
|
|
|
*/
|
|
|
|
yylineno = strtol(ptr, &ptr, 0) - 1;
|
|
|
|
yylloc->source = strtol(ptr, NULL, 0);
|
|
|
|
}
|
|
|
|
{HASH}line{SPCP}{INT}{SPC}$ {
|
|
|
|
/* Eat characters until the first digit is
|
|
|
|
* encountered
|
|
|
|
*/
|
|
|
|
char *ptr = yytext;
|
|
|
|
while (!isdigit(*ptr))
|
|
|
|
ptr++;
|
|
|
|
|
|
|
|
/* Subtract one from the line number because
|
|
|
|
* yylineno is zero-based instead of
|
|
|
|
* one-based.
|
|
|
|
*/
|
|
|
|
yylineno = strtol(ptr, &ptr, 0) - 1;
|
|
|
|
}
|
2010-08-30 11:58:04 -07:00
|
|
|
^{SPC}#{SPC}pragma{SPCP}debug{SPC}\({SPC}on{SPC}\) {
|
|
|
|
BEGIN PP;
|
|
|
|
return PRAGMA_DEBUG_ON;
|
|
|
|
}
|
|
|
|
^{SPC}#{SPC}pragma{SPCP}debug{SPC}\({SPC}off{SPC}\) {
|
|
|
|
BEGIN PP;
|
|
|
|
return PRAGMA_DEBUG_OFF;
|
|
|
|
}
|
|
|
|
^{SPC}#{SPC}pragma{SPCP}optimize{SPC}\({SPC}on{SPC}\) {
|
|
|
|
BEGIN PP;
|
|
|
|
return PRAGMA_OPTIMIZE_ON;
|
|
|
|
}
|
|
|
|
^{SPC}#{SPC}pragma{SPCP}optimize{SPC}\({SPC}off{SPC}\) {
|
|
|
|
BEGIN PP;
|
|
|
|
return PRAGMA_OPTIMIZE_OFF;
|
|
|
|
}
|
2011-01-06 10:49:56 -08:00
|
|
|
^{SPC}#{SPC}pragma{SPCP}STDGL{SPCP}invariant{SPC}\({SPC}all{SPC}\) {
|
|
|
|
BEGIN PP;
|
|
|
|
return PRAGMA_INVARIANT_ALL;
|
|
|
|
}
|
2010-08-30 11:58:04 -07:00
|
|
|
^{SPC}#{SPC}pragma{SPCP} { BEGIN PRAGMA; }
|
|
|
|
|
|
|
|
<PRAGMA>\n { BEGIN 0; yylineno++; yycolumn = 0; }
|
|
|
|
<PRAGMA>. { }
|
|
|
|
|
2010-04-07 13:43:52 -07:00
|
|
|
<PP>\/\/[^\n]* { }
|
2010-04-07 14:49:59 -07:00
|
|
|
<PP>[ \t\r]* { }
|
2010-02-22 13:19:34 -08:00
|
|
|
<PP>: return COLON;
|
|
|
|
<PP>[_a-zA-Z][_a-zA-Z0-9]* {
|
|
|
|
yylval->identifier = strdup(yytext);
|
|
|
|
return IDENTIFIER;
|
|
|
|
}
|
|
|
|
<PP>[1-9][0-9]* {
|
|
|
|
yylval->n = strtol(yytext, NULL, 10);
|
|
|
|
return INTCONSTANT;
|
|
|
|
}
|
|
|
|
<PP>\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; }
|
|
|
|
|
|
|
|
\n { yylineno++; yycolumn = 0; }
|
|
|
|
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
attribute DEPRECATED_ES_KEYWORD(ATTRIBUTE);
|
2010-06-30 16:40:47 -07:00
|
|
|
const return CONST_TOK;
|
2010-08-13 09:23:54 -07:00
|
|
|
bool return BOOL_TOK;
|
|
|
|
float return FLOAT_TOK;
|
|
|
|
int return INT_TOK;
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
uint KEYWORD(130, 300, 130, 300, UINT_TOK);
|
2010-02-22 13:19:34 -08:00
|
|
|
|
|
|
|
break return BREAK;
|
|
|
|
continue return CONTINUE;
|
|
|
|
do return DO;
|
|
|
|
while return WHILE;
|
|
|
|
else return ELSE;
|
|
|
|
for return FOR;
|
|
|
|
if return IF;
|
|
|
|
discard return DISCARD;
|
|
|
|
return return RETURN;
|
|
|
|
|
|
|
|
bvec2 return BVEC2;
|
|
|
|
bvec3 return BVEC3;
|
|
|
|
bvec4 return BVEC4;
|
|
|
|
ivec2 return IVEC2;
|
|
|
|
ivec3 return IVEC3;
|
|
|
|
ivec4 return IVEC4;
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
uvec2 KEYWORD(130, 300, 130, 300, UVEC2);
|
|
|
|
uvec3 KEYWORD(130, 300, 130, 300, UVEC3);
|
|
|
|
uvec4 KEYWORD(130, 300, 130, 300, UVEC4);
|
2010-02-22 13:19:34 -08:00
|
|
|
vec2 return VEC2;
|
|
|
|
vec3 return VEC3;
|
|
|
|
vec4 return VEC4;
|
2010-08-13 09:26:01 -07:00
|
|
|
mat2 return MAT2X2;
|
|
|
|
mat3 return MAT3X3;
|
|
|
|
mat4 return MAT4X4;
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
mat2x2 KEYWORD(120, 300, 120, 300, MAT2X2);
|
|
|
|
mat2x3 KEYWORD(120, 300, 120, 300, MAT2X3);
|
|
|
|
mat2x4 KEYWORD(120, 300, 120, 300, MAT2X4);
|
|
|
|
mat3x2 KEYWORD(120, 300, 120, 300, MAT3X2);
|
|
|
|
mat3x3 KEYWORD(120, 300, 120, 300, MAT3X3);
|
|
|
|
mat3x4 KEYWORD(120, 300, 120, 300, MAT3X4);
|
|
|
|
mat4x2 KEYWORD(120, 300, 120, 300, MAT4X2);
|
|
|
|
mat4x3 KEYWORD(120, 300, 120, 300, MAT4X3);
|
|
|
|
mat4x4 KEYWORD(120, 300, 120, 300, MAT4X4);
|
2010-02-22 13:19:34 -08:00
|
|
|
|
2010-08-13 09:23:54 -07:00
|
|
|
in return IN_TOK;
|
|
|
|
out return OUT_TOK;
|
|
|
|
inout return INOUT_TOK;
|
2010-02-22 13:19:34 -08:00
|
|
|
uniform return UNIFORM;
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
varying DEPRECATED_ES_KEYWORD(VARYING);
|
|
|
|
centroid KEYWORD(120, 300, 120, 300, CENTROID);
|
2012-08-01 19:04:59 -07:00
|
|
|
invariant KEYWORD(120, 100, 120, 100, INVARIANT);
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
flat KEYWORD(130, 100, 130, 300, FLAT);
|
|
|
|
smooth KEYWORD(130, 300, 130, 300, SMOOTH);
|
|
|
|
noperspective KEYWORD(130, 300, 130, 0, NOPERSPECTIVE);
|
2010-06-18 18:36:51 -07:00
|
|
|
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
sampler1D DEPRECATED_ES_KEYWORD(SAMPLER1D);
|
2010-02-22 13:19:34 -08:00
|
|
|
sampler2D return SAMPLER2D;
|
|
|
|
sampler3D return SAMPLER3D;
|
|
|
|
samplerCube return SAMPLERCUBE;
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
sampler1DArray KEYWORD(130, 300, 130, 0, SAMPLER1DARRAY);
|
|
|
|
sampler2DArray KEYWORD(130, 300, 130, 300, SAMPLER2DARRAY);
|
|
|
|
sampler1DShadow DEPRECATED_ES_KEYWORD(SAMPLER1DSHADOW);
|
2010-02-22 13:19:34 -08:00
|
|
|
sampler2DShadow return SAMPLER2DSHADOW;
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
samplerCubeShadow KEYWORD(130, 300, 130, 300, SAMPLERCUBESHADOW);
|
|
|
|
sampler1DArrayShadow KEYWORD(130, 300, 130, 0, SAMPLER1DARRAYSHADOW);
|
|
|
|
sampler2DArrayShadow KEYWORD(130, 300, 130, 300, SAMPLER2DARRAYSHADOW);
|
|
|
|
isampler1D KEYWORD(130, 300, 130, 0, ISAMPLER1D);
|
|
|
|
isampler2D KEYWORD(130, 300, 130, 300, ISAMPLER2D);
|
|
|
|
isampler3D KEYWORD(130, 300, 130, 300, ISAMPLER3D);
|
|
|
|
isamplerCube KEYWORD(130, 300, 130, 300, ISAMPLERCUBE);
|
|
|
|
isampler1DArray KEYWORD(130, 300, 130, 0, ISAMPLER1DARRAY);
|
|
|
|
isampler2DArray KEYWORD(130, 300, 130, 300, ISAMPLER2DARRAY);
|
|
|
|
usampler1D KEYWORD(130, 300, 130, 0, USAMPLER1D);
|
|
|
|
usampler2D KEYWORD(130, 300, 130, 300, USAMPLER2D);
|
|
|
|
usampler3D KEYWORD(130, 300, 130, 300, USAMPLER3D);
|
|
|
|
usamplerCube KEYWORD(130, 300, 130, 300, USAMPLERCUBE);
|
|
|
|
usampler1DArray KEYWORD(130, 300, 130, 0, USAMPLER1DARRAY);
|
|
|
|
usampler2DArray KEYWORD(130, 300, 130, 300, USAMPLER2DARRAY);
|
2010-11-13 22:02:09 -08:00
|
|
|
|
2012-12-21 21:33:37 +13:00
|
|
|
/* additional keywords in ARB_texture_multisample, included in GLSL 1.50 */
|
|
|
|
/* these are reserved but not defined in GLSL 3.00 */
|
|
|
|
sampler2DMS KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, SAMPLER2DMS);
|
|
|
|
isampler2DMS KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, ISAMPLER2DMS);
|
|
|
|
usampler2DMS KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, USAMPLER2DMS);
|
|
|
|
sampler2DMSArray KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, SAMPLER2DMSARRAY);
|
|
|
|
isampler2DMSArray KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, ISAMPLER2DMSARRAY);
|
|
|
|
usampler2DMSArray KEYWORD_WITH_ALT(150, 300, 150, 0, yyextra->ARB_texture_multisample_enable, USAMPLER2DMSARRAY);
|
|
|
|
|
2013-07-26 10:21:56 +03:00
|
|
|
/* keywords available with ARB_texture_cube_map_array_enable extension on desktop GLSL */
|
|
|
|
samplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, SAMPLERCUBEARRAY);
|
|
|
|
isamplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, ISAMPLERCUBEARRAY);
|
|
|
|
usamplerCubeArray KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, USAMPLERCUBEARRAY);
|
|
|
|
samplerCubeArrayShadow KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_texture_cube_map_array_enable, SAMPLERCUBEARRAYSHADOW);
|
2012-11-03 20:43:17 +10:00
|
|
|
|
|
|
|
samplerExternalOES {
|
2011-10-23 18:51:06 +08:00
|
|
|
if (yyextra->OES_EGL_image_external_enable)
|
|
|
|
return SAMPLEREXTERNALOES;
|
|
|
|
else
|
|
|
|
return IDENTIFIER;
|
2012-11-03 20:43:17 +10:00
|
|
|
}
|
2011-10-23 18:51:06 +08:00
|
|
|
|
2010-02-22 13:19:34 -08:00
|
|
|
|
|
|
|
struct return STRUCT;
|
2010-08-13 09:23:54 -07:00
|
|
|
void return VOID_TOK;
|
2010-02-22 13:19:34 -08:00
|
|
|
|
2010-06-30 17:30:03 -07:00
|
|
|
layout {
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
if ((yyextra->is_version(140, 300))
|
2011-01-27 01:40:14 -08:00
|
|
|
|| yyextra->AMD_conservative_depth_enable
|
2011-11-19 16:41:08 +01:00
|
|
|
|| yyextra->ARB_conservative_depth_enable
|
2010-10-05 17:00:31 -07:00
|
|
|
|| yyextra->ARB_explicit_attrib_location_enable
|
2012-04-18 13:35:56 -07:00
|
|
|
|| yyextra->ARB_uniform_buffer_object_enable
|
2013-07-17 10:39:59 -07:00
|
|
|
|| yyextra->ARB_fragment_coord_conventions_enable
|
|
|
|
|| yyextra->ARB_shading_language_420pack_enable) {
|
2010-06-30 17:30:03 -07:00
|
|
|
return LAYOUT_TOK;
|
|
|
|
} else {
|
|
|
|
yylval->identifier = strdup(yytext);
|
|
|
|
return IDENTIFIER;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-22 13:19:34 -08:00
|
|
|
\+\+ return INC_OP;
|
|
|
|
-- return DEC_OP;
|
|
|
|
\<= return LE_OP;
|
|
|
|
>= return GE_OP;
|
|
|
|
== return EQ_OP;
|
|
|
|
!= return NE_OP;
|
|
|
|
&& return AND_OP;
|
|
|
|
\|\| return OR_OP;
|
|
|
|
"^^" return XOR_OP;
|
2010-10-08 16:12:24 -07:00
|
|
|
"<<" return LEFT_OP;
|
|
|
|
">>" return RIGHT_OP;
|
2010-02-22 13:19:34 -08:00
|
|
|
|
|
|
|
\*= return MUL_ASSIGN;
|
|
|
|
\/= return DIV_ASSIGN;
|
|
|
|
\+= return ADD_ASSIGN;
|
|
|
|
\%= return MOD_ASSIGN;
|
|
|
|
\<\<= return LEFT_ASSIGN;
|
|
|
|
>>= return RIGHT_ASSIGN;
|
|
|
|
&= return AND_ASSIGN;
|
2010-10-15 14:44:28 -07:00
|
|
|
"^=" return XOR_ASSIGN;
|
2010-02-22 13:19:34 -08:00
|
|
|
\|= return OR_ASSIGN;
|
|
|
|
-= return SUB_ASSIGN;
|
|
|
|
|
2010-11-13 23:09:43 -08:00
|
|
|
[1-9][0-9]*[uU]? {
|
2011-10-03 16:59:01 -07:00
|
|
|
return LITERAL_INTEGER(10);
|
2010-02-22 13:19:34 -08:00
|
|
|
}
|
2010-11-13 23:09:43 -08:00
|
|
|
0[xX][0-9a-fA-F]+[uU]? {
|
2011-10-03 16:59:01 -07:00
|
|
|
return LITERAL_INTEGER(16);
|
2010-02-22 13:19:34 -08:00
|
|
|
}
|
2010-11-13 23:09:43 -08:00
|
|
|
0[0-7]*[uU]? {
|
2011-10-03 16:59:01 -07:00
|
|
|
return LITERAL_INTEGER(8);
|
2010-02-22 13:19:34 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? {
|
2013-01-22 17:50:53 -07:00
|
|
|
yylval->real = glsl_strtof(yytext, NULL);
|
2010-02-22 13:19:34 -08:00
|
|
|
return FLOATCONSTANT;
|
|
|
|
}
|
|
|
|
\.[0-9]+([eE][+-]?[0-9]+)?[fF]? {
|
2013-01-22 17:50:53 -07:00
|
|
|
yylval->real = glsl_strtof(yytext, NULL);
|
2010-02-22 13:19:34 -08:00
|
|
|
return FLOATCONSTANT;
|
|
|
|
}
|
|
|
|
[0-9]+\.([eE][+-]?[0-9]+)?[fF]? {
|
2013-01-22 17:50:53 -07:00
|
|
|
yylval->real = glsl_strtof(yytext, NULL);
|
2010-02-22 13:19:34 -08:00
|
|
|
return FLOATCONSTANT;
|
|
|
|
}
|
|
|
|
[0-9]+[eE][+-]?[0-9]+[fF]? {
|
2013-01-22 17:50:53 -07:00
|
|
|
yylval->real = glsl_strtof(yytext, NULL);
|
2010-02-22 13:19:34 -08:00
|
|
|
return FLOATCONSTANT;
|
|
|
|
}
|
2010-08-02 11:26:43 -07:00
|
|
|
[0-9]+[fF] {
|
2013-01-22 17:50:53 -07:00
|
|
|
yylval->real = glsl_strtof(yytext, NULL);
|
2010-08-02 11:26:43 -07:00
|
|
|
return FLOATCONSTANT;
|
|
|
|
}
|
2010-02-22 13:19:34 -08:00
|
|
|
|
|
|
|
true {
|
|
|
|
yylval->n = 1;
|
|
|
|
return BOOLCONSTANT;
|
|
|
|
}
|
|
|
|
false {
|
|
|
|
yylval->n = 0;
|
|
|
|
return BOOLCONSTANT;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Reserved words in GLSL 1.10. */
|
2012-08-01 19:04:59 -07:00
|
|
|
asm KEYWORD(110, 100, 0, 0, ASM);
|
|
|
|
class KEYWORD(110, 100, 0, 0, CLASS);
|
|
|
|
union KEYWORD(110, 100, 0, 0, UNION);
|
|
|
|
enum KEYWORD(110, 100, 0, 0, ENUM);
|
|
|
|
typedef KEYWORD(110, 100, 0, 0, TYPEDEF);
|
|
|
|
template KEYWORD(110, 100, 0, 0, TEMPLATE);
|
|
|
|
this KEYWORD(110, 100, 0, 0, THIS);
|
2012-11-09 12:26:42 -08:00
|
|
|
packed KEYWORD_WITH_ALT(110, 100, 140, 300, yyextra->ARB_uniform_buffer_object_enable, PACKED_TOK);
|
2012-08-01 19:04:59 -07:00
|
|
|
goto KEYWORD(110, 100, 0, 0, GOTO);
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
switch KEYWORD(110, 100, 130, 300, SWITCH);
|
|
|
|
default KEYWORD(110, 100, 130, 300, DEFAULT);
|
2012-08-01 19:04:59 -07:00
|
|
|
inline KEYWORD(110, 100, 0, 0, INLINE_TOK);
|
|
|
|
noinline KEYWORD(110, 100, 0, 0, NOINLINE);
|
|
|
|
volatile KEYWORD(110, 100, 0, 0, VOLATILE);
|
|
|
|
public KEYWORD(110, 100, 0, 0, PUBLIC_TOK);
|
|
|
|
static KEYWORD(110, 100, 0, 0, STATIC);
|
|
|
|
extern KEYWORD(110, 100, 0, 0, EXTERN);
|
|
|
|
external KEYWORD(110, 100, 0, 0, EXTERNAL);
|
|
|
|
interface KEYWORD(110, 100, 0, 0, INTERFACE);
|
|
|
|
long KEYWORD(110, 100, 0, 0, LONG_TOK);
|
|
|
|
short KEYWORD(110, 100, 0, 0, SHORT_TOK);
|
|
|
|
double KEYWORD(110, 100, 400, 0, DOUBLE_TOK);
|
|
|
|
half KEYWORD(110, 100, 0, 0, HALF);
|
|
|
|
fixed KEYWORD(110, 100, 0, 0, FIXED_TOK);
|
|
|
|
unsigned KEYWORD(110, 100, 0, 0, UNSIGNED);
|
|
|
|
input KEYWORD(110, 100, 0, 0, INPUT_TOK);
|
|
|
|
output KEYWORD(110, 100, 0, 0, OUTPUT);
|
|
|
|
hvec2 KEYWORD(110, 100, 0, 0, HVEC2);
|
|
|
|
hvec3 KEYWORD(110, 100, 0, 0, HVEC3);
|
|
|
|
hvec4 KEYWORD(110, 100, 0, 0, HVEC4);
|
|
|
|
dvec2 KEYWORD(110, 100, 400, 0, DVEC2);
|
|
|
|
dvec3 KEYWORD(110, 100, 400, 0, DVEC3);
|
|
|
|
dvec4 KEYWORD(110, 100, 400, 0, DVEC4);
|
|
|
|
fvec2 KEYWORD(110, 100, 0, 0, FVEC2);
|
|
|
|
fvec3 KEYWORD(110, 100, 0, 0, FVEC3);
|
|
|
|
fvec4 KEYWORD(110, 100, 0, 0, FVEC4);
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
sampler2DRect DEPRECATED_ES_KEYWORD(SAMPLER2DRECT);
|
2012-08-01 19:04:59 -07:00
|
|
|
sampler3DRect KEYWORD(110, 100, 0, 0, SAMPLER3DRECT);
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
sampler2DRectShadow DEPRECATED_ES_KEYWORD(SAMPLER2DRECTSHADOW);
|
2012-08-01 19:04:59 -07:00
|
|
|
sizeof KEYWORD(110, 100, 0, 0, SIZEOF);
|
|
|
|
cast KEYWORD(110, 100, 0, 0, CAST);
|
|
|
|
namespace KEYWORD(110, 100, 0, 0, NAMESPACE);
|
|
|
|
using KEYWORD(110, 100, 0, 0, USING);
|
2010-02-22 13:19:34 -08:00
|
|
|
|
|
|
|
/* Additional reserved words in GLSL 1.20. */
|
2012-08-01 19:04:59 -07:00
|
|
|
lowp KEYWORD(120, 100, 130, 100, LOWP);
|
|
|
|
mediump KEYWORD(120, 100, 130, 100, MEDIUMP);
|
|
|
|
highp KEYWORD(120, 100, 130, 100, HIGHP);
|
|
|
|
precision KEYWORD(120, 100, 130, 100, PRECISION);
|
2010-02-22 13:19:34 -08:00
|
|
|
|
2010-08-07 00:50:08 -07:00
|
|
|
/* Additional reserved words in GLSL 1.30. */
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
case KEYWORD(130, 300, 130, 300, CASE);
|
|
|
|
common KEYWORD(130, 300, 0, 0, COMMON);
|
|
|
|
partition KEYWORD(130, 300, 0, 0, PARTITION);
|
|
|
|
active KEYWORD(130, 300, 0, 0, ACTIVE);
|
2012-08-01 19:04:59 -07:00
|
|
|
superp KEYWORD(130, 100, 0, 0, SUPERP);
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
samplerBuffer KEYWORD(130, 300, 140, 0, SAMPLERBUFFER);
|
|
|
|
filter KEYWORD(130, 300, 0, 0, FILTER);
|
|
|
|
image1D KEYWORD(130, 300, 0, 0, IMAGE1D);
|
|
|
|
image2D KEYWORD(130, 300, 0, 0, IMAGE2D);
|
|
|
|
image3D KEYWORD(130, 300, 0, 0, IMAGE3D);
|
|
|
|
imageCube KEYWORD(130, 300, 0, 0, IMAGECUBE);
|
|
|
|
iimage1D KEYWORD(130, 300, 0, 0, IIMAGE1D);
|
|
|
|
iimage2D KEYWORD(130, 300, 0, 0, IIMAGE2D);
|
|
|
|
iimage3D KEYWORD(130, 300, 0, 0, IIMAGE3D);
|
|
|
|
iimageCube KEYWORD(130, 300, 0, 0, IIMAGECUBE);
|
|
|
|
uimage1D KEYWORD(130, 300, 0, 0, UIMAGE1D);
|
|
|
|
uimage2D KEYWORD(130, 300, 0, 0, UIMAGE2D);
|
|
|
|
uimage3D KEYWORD(130, 300, 0, 0, UIMAGE3D);
|
|
|
|
uimageCube KEYWORD(130, 300, 0, 0, UIMAGECUBE);
|
|
|
|
image1DArray KEYWORD(130, 300, 0, 0, IMAGE1DARRAY);
|
|
|
|
image2DArray KEYWORD(130, 300, 0, 0, IMAGE2DARRAY);
|
|
|
|
iimage1DArray KEYWORD(130, 300, 0, 0, IIMAGE1DARRAY);
|
|
|
|
iimage2DArray KEYWORD(130, 300, 0, 0, IIMAGE2DARRAY);
|
|
|
|
uimage1DArray KEYWORD(130, 300, 0, 0, UIMAGE1DARRAY);
|
|
|
|
uimage2DArray KEYWORD(130, 300, 0, 0, UIMAGE2DARRAY);
|
|
|
|
image1DShadow KEYWORD(130, 300, 0, 0, IMAGE1DSHADOW);
|
|
|
|
image2DShadow KEYWORD(130, 300, 0, 0, IMAGE2DSHADOW);
|
|
|
|
image1DArrayShadow KEYWORD(130, 300, 0, 0, IMAGE1DARRAYSHADOW);
|
|
|
|
image2DArrayShadow KEYWORD(130, 300, 0, 0, IMAGE2DARRAYSHADOW);
|
|
|
|
imageBuffer KEYWORD(130, 300, 0, 0, IMAGEBUFFER);
|
|
|
|
iimageBuffer KEYWORD(130, 300, 0, 0, IIMAGEBUFFER);
|
|
|
|
uimageBuffer KEYWORD(130, 300, 0, 0, UIMAGEBUFFER);
|
2013-07-11 10:11:18 -07:00
|
|
|
row_major KEYWORD_WITH_ALT(130, 0, 140, 0, yyextra->ARB_uniform_buffer_object_enable && !yyextra->es_shader, ROW_MAJOR);
|
2010-08-07 00:50:08 -07:00
|
|
|
|
2012-04-13 12:34:45 -07:00
|
|
|
/* Additional reserved words in GLSL 1.40 */
|
glsl: parse GLSL ES 3.00 keywords correctly.
GLSL ES 3.00 adds the following keywords over GLSL 1.00: uint,
uvec[2-4], matNxM, centroid, flat, smooth, various samplers, layout,
switch, default, and case.
Additionally, it reserves a large number of keywords, some of which
were already reserved in versions of desktop GL that Mesa supports,
some of which are new to Mesa.
A few of the reserved keywords in GLSL ES 3.00 are keywords that are
supported in all other versions of GLSL: attribute, varying,
sampler1D, sampler1DShador, sampler2DRect, and sampler2DRectShadow.
This patch updates the lexer to handle all of the new keywords
correctly when the language being parsed is GLSL 3.00 ES.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2012-08-02 08:17:55 -07:00
|
|
|
isampler2DRect KEYWORD(140, 300, 140, 0, ISAMPLER2DRECT);
|
|
|
|
usampler2DRect KEYWORD(140, 300, 140, 0, USAMPLER2DRECT);
|
|
|
|
isamplerBuffer KEYWORD(140, 300, 140, 0, ISAMPLERBUFFER);
|
|
|
|
usamplerBuffer KEYWORD(140, 300, 140, 0, USAMPLERBUFFER);
|
|
|
|
|
|
|
|
/* Additional reserved words in GLSL ES 3.00 */
|
|
|
|
coherent KEYWORD(0, 300, 0, 0, COHERENT);
|
|
|
|
restrict KEYWORD(0, 300, 0, 0, RESTRICT);
|
|
|
|
readonly KEYWORD(0, 300, 0, 0, READONLY);
|
|
|
|
writeonly KEYWORD(0, 300, 0, 0, WRITEONLY);
|
|
|
|
resource KEYWORD(0, 300, 0, 0, RESOURCE);
|
|
|
|
atomic_uint KEYWORD(0, 300, 0, 0, ATOMIC_UINT);
|
|
|
|
patch KEYWORD(0, 300, 0, 0, PATCH);
|
|
|
|
sample KEYWORD(0, 300, 0, 0, SAMPLE);
|
|
|
|
subroutine KEYWORD(0, 300, 0, 0, SUBROUTINE);
|
|
|
|
|
2012-04-13 12:34:45 -07:00
|
|
|
|
2010-02-22 13:19:34 -08:00
|
|
|
[_a-zA-Z][_a-zA-Z0-9]* {
|
2010-06-18 17:43:40 -07:00
|
|
|
struct _mesa_glsl_parse_state *state = yyextra;
|
2010-06-25 13:14:37 -07:00
|
|
|
void *ctx = state;
|
2011-01-21 14:32:31 -08:00
|
|
|
yylval->identifier = ralloc_strdup(ctx, yytext);
|
2011-01-27 17:52:19 -08:00
|
|
|
return classify_identifier(state, yytext);
|
2010-02-22 13:19:34 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
. { return yytext[0]; }
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
2011-01-27 17:52:19 -08:00
|
|
|
int
|
|
|
|
classify_identifier(struct _mesa_glsl_parse_state *state, const char *name)
|
|
|
|
{
|
|
|
|
if (state->symbols->get_variable(name) || state->symbols->get_function(name))
|
|
|
|
return IDENTIFIER;
|
|
|
|
else if (state->symbols->get_type(name))
|
|
|
|
return TYPE_IDENTIFIER;
|
|
|
|
else
|
|
|
|
return NEW_IDENTIFIER;
|
|
|
|
}
|
|
|
|
|
2010-02-22 13:19:34 -08:00
|
|
|
void
|
2010-06-21 11:43:42 -07:00
|
|
|
_mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state, const char *string)
|
2010-02-22 13:19:34 -08:00
|
|
|
{
|
|
|
|
yylex_init_extra(state, & state->scanner);
|
2010-06-21 11:43:42 -07:00
|
|
|
yy_scan_string(string, state->scanner);
|
2010-02-22 13:19:34 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state)
|
|
|
|
{
|
|
|
|
yylex_destroy(state->scanner);
|
|
|
|
}
|