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>
|
2014-08-20 14:40:22 +08:00
|
|
|
#include "util/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->first_column = yycolumn + 1; \
|
2014-02-05 21:18:08 +06:00
|
|
|
yylloc->first_line = yylloc->last_line = yylineno + 1; \
|
2010-02-22 13:19:34 -08:00
|
|
|
yycolumn += yyleng; \
|
2014-02-05 21:18:08 +06:00
|
|
|
yylloc->last_column = yycolumn + 1; \
|
2010-02-22 13:19:34 -08:00
|
|
|
} while(0);
|
|
|
|
|
2015-03-17 19:28:25 +01:00
|
|
|
#define YY_USER_INIT yylineno = 0; yycolumn = 0; yylloc->source = 0;
|
2010-07-07 11:40:51 -07:00
|
|
|
|
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, \
|
2013-07-25 19:56:43 -07:00
|
|
|
"illegal use of reserved word `%s'", yytext); \
|
2010-08-11 17:01:31 -07:00
|
|
|
return ERROR_TOK; \
|
2010-11-13 20:32:59 -08:00
|
|
|
} else { \
|
2014-09-03 16:38:31 +03:00
|
|
|
void *mem_ctx = yyextra; \
|
|
|
|
yylval->identifier = ralloc_strdup(mem_ctx, 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, \
|
2013-07-25 19:56:43 -07:00
|
|
|
"illegal use of reserved word `%s'", yytext); \
|
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
|
|
|
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,
|
2013-07-25 19:56:43 -07:00
|
|
|
"literal value `%s' out of range", text);
|
2011-10-03 16:59:01 -07:00
|
|
|
} else {
|
|
|
|
_mesa_glsl_warning(lloc, state,
|
2013-07-25 19:56:43 -07:00
|
|
|
"literal value `%s' out of range", text);
|
2011-10-03 16:59:01 -07:00
|
|
|
}
|
|
|
|
} 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,
|
2013-07-25 19:56:43 -07:00
|
|
|
"signed literal value `%s' is interpreted as %d",
|
2011-10-03 16:59:01 -07:00
|
|
|
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
|
2013-07-29 15:27:46 -07:00
|
|
|
%option prefix="_mesa_glsl_lexer_"
|
2010-02-22 13:19:34 -08:00
|
|
|
%option extra-type="struct _mesa_glsl_parse_state *"
|
2014-07-01 15:10:02 -07:00
|
|
|
%option warn nodefault
|
2010-02-22 13:19:34 -08:00
|
|
|
|
2014-06-25 13:07:44 -07:00
|
|
|
/* Note: When adding any start conditions to this list, you must also
|
|
|
|
* update the "Internal compiler error" catch-all rule near the end of
|
|
|
|
* this file. */
|
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]* {
|
2014-09-03 16:38:31 +03:00
|
|
|
void *mem_ctx = yyextra;
|
|
|
|
yylval->identifier = ralloc_strdup(mem_ctx, yytext);
|
2010-02-22 13:19:34 -08:00
|
|
|
return IDENTIFIER;
|
|
|
|
}
|
|
|
|
<PP>[1-9][0-9]* {
|
|
|
|
yylval->n = strtol(yytext, NULL, 10);
|
|
|
|
return INTCONSTANT;
|
|
|
|
}
|
|
|
|
<PP>\n { BEGIN 0; yylineno++; yycolumn = 0; return EOL; }
|
glsl: Properly lex extra tokens when handling # directives.
Without this, in the <PP> state, we would hit Flex's default rule, which
prints tokens to stdout, rather than returning them as tokens. (Or, after the
previous commit, we would hit the new catch-all rule and generate an internal
compiler error.)
With this commit in place, we generate the desired syntax error.
This manifested as a weird bug where shaders with semicolons after
extension directives, such as:
#extension GL_foo_bar : enable;
would print semicolons to the screen, but otherwise compile just fine
(even though this is illegal).
Fixes Piglit's extension-semicolon.frag test.
This also fixes the following Khronos GLES3 conformance tests, (and for real
this time):
invalid_char_in_name_vertex
invalid_char_in_name_fragment
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
2014-06-11 22:04:09 -07:00
|
|
|
<PP>. { return yytext[0]; }
|
2010-02-22 13:19:34 -08:00
|
|
|
|
|
|
|
\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
|
|
|
|
2014-04-27 16:03:53 +12:00
|
|
|
/* keywords available with ARB_gpu_shader5 */
|
|
|
|
precise KEYWORD_WITH_ALT(400, 0, 400, 0, yyextra->ARB_gpu_shader5_enable, PRECISE);
|
|
|
|
|
2013-11-25 14:59:46 -08:00
|
|
|
/* keywords available with ARB_shader_image_load_store */
|
|
|
|
image1D KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE1D);
|
|
|
|
image2D KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE2D);
|
|
|
|
image3D KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE3D);
|
|
|
|
image2DRect KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE2DRECT);
|
|
|
|
imageCube KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGECUBE);
|
|
|
|
imageBuffer KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGEBUFFER);
|
|
|
|
image1DArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE1DARRAY);
|
|
|
|
image2DArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE2DARRAY);
|
|
|
|
imageCubeArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGECUBEARRAY);
|
|
|
|
image2DMS KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE2DMS);
|
|
|
|
image2DMSArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IMAGE2DMSARRAY);
|
|
|
|
iimage1D KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE1D);
|
|
|
|
iimage2D KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE2D);
|
|
|
|
iimage3D KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE3D);
|
|
|
|
iimage2DRect KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE2DRECT);
|
|
|
|
iimageCube KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGECUBE);
|
|
|
|
iimageBuffer KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGEBUFFER);
|
|
|
|
iimage1DArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE1DARRAY);
|
|
|
|
iimage2DArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE2DARRAY);
|
|
|
|
iimageCubeArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGECUBEARRAY);
|
|
|
|
iimage2DMS KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE2DMS);
|
|
|
|
iimage2DMSArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, IIMAGE2DMSARRAY);
|
|
|
|
uimage1D KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE1D);
|
|
|
|
uimage2D KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE2D);
|
|
|
|
uimage3D KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE3D);
|
|
|
|
uimage2DRect KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE2DRECT);
|
|
|
|
uimageCube KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGECUBE);
|
|
|
|
uimageBuffer KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGEBUFFER);
|
|
|
|
uimage1DArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE1DARRAY);
|
|
|
|
uimage2DArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE2DARRAY);
|
|
|
|
uimageCubeArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGECUBEARRAY);
|
|
|
|
uimage2DMS KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE2DMS);
|
|
|
|
uimage2DMSArray KEYWORD_WITH_ALT(130, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, UIMAGE2DMSARRAY);
|
|
|
|
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);
|
|
|
|
|
|
|
|
coherent KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, COHERENT);
|
|
|
|
volatile KEYWORD_WITH_ALT(110, 100, 420, 0, yyextra->ARB_shader_image_load_store_enable, VOLATILE);
|
|
|
|
restrict KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, RESTRICT);
|
|
|
|
readonly KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, READONLY);
|
|
|
|
writeonly KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, WRITEONLY);
|
|
|
|
|
2013-10-20 12:38:07 -07:00
|
|
|
atomic_uint KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_atomic_counters_enable, ATOMIC_UINT);
|
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
|
2014-03-05 12:35:03 +02:00
|
|
|
|| yyextra->ARB_explicit_uniform_location_enable
|
2013-09-25 16:16:00 -07:00
|
|
|
|| yyextra->has_separate_shader_objects()
|
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
|
2014-01-06 09:09:31 -08:00
|
|
|
|| yyextra->ARB_shading_language_420pack_enable
|
|
|
|
|| yyextra->ARB_compute_shader_enable) {
|
2010-06-30 17:30:03 -07:00
|
|
|
return LAYOUT_TOK;
|
|
|
|
} else {
|
2014-09-03 16:38:31 +03:00
|
|
|
void *mem_ctx = yyextra;
|
|
|
|
yylval->identifier = ralloc_strdup(mem_ctx, yytext);
|
2013-07-26 12:31:06 -07:00
|
|
|
return classify_identifier(yyextra, yytext);
|
2010-06-30 17:30:03 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-11-26 17:57:42 +00:00
|
|
|
[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?[fF]? |
|
|
|
|
\.[0-9]+([eE][+-]?[0-9]+)?[fF]? |
|
|
|
|
[0-9]+\.([eE][+-]?[0-9]+)?[fF]? |
|
2010-02-22 13:19:34 -08:00
|
|
|
[0-9]+[eE][+-]?[0-9]+[fF]? {
|
2014-08-20 14:40:22 +08:00
|
|
|
yylval->real = _mesa_strtof(yytext, NULL);
|
2010-02-22 13:19:34 -08:00
|
|
|
return FLOATCONSTANT;
|
|
|
|
}
|
|
|
|
|
2015-02-05 12:07:34 +02:00
|
|
|
[0-9]+\.[0-9]+([eE][+-]?[0-9]+)?(lf|LF) |
|
|
|
|
\.[0-9]+([eE][+-]?[0-9]+)?(lf|LF) |
|
|
|
|
[0-9]+\.([eE][+-]?[0-9]+)?(lf|LF) |
|
|
|
|
[0-9]+[eE][+-]?[0-9]+(lf|LF) {
|
|
|
|
if (!yyextra->is_version(400, 0) &&
|
|
|
|
!yyextra->ARB_gpu_shader_fp64_enable)
|
|
|
|
return ERROR_TOK;
|
|
|
|
yylval->dreal = _mesa_strtod(yytext, NULL);
|
|
|
|
return DOUBLECONSTANT;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
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);
|
2015-02-05 12:07:34 +02:00
|
|
|
double KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DOUBLE_TOK);
|
2012-08-01 19:04:59 -07:00
|
|
|
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);
|
2015-02-05 12:07:34 +02:00
|
|
|
dvec2 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DVEC2);
|
|
|
|
dvec3 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DVEC3);
|
|
|
|
dvec4 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DVEC4);
|
|
|
|
dmat2 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT2X2);
|
|
|
|
dmat3 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT3X3);
|
|
|
|
dmat4 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT4X4);
|
|
|
|
dmat2x2 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT2X2);
|
|
|
|
dmat2x3 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT2X3);
|
|
|
|
dmat2x4 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT2X4);
|
|
|
|
dmat3x2 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT3X2);
|
|
|
|
dmat3x3 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT3X3);
|
|
|
|
dmat3x4 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT3X4);
|
|
|
|
dmat4x2 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT4X2);
|
|
|
|
dmat4x3 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT4X3);
|
|
|
|
dmat4x4 KEYWORD_WITH_ALT(110, 100, 400, 0, yyextra->ARB_gpu_shader_fp64_enable, DMAT4X4);
|
2012-08-01 19:04:59 -07:00
|
|
|
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);
|
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 */
|
|
|
|
resource KEYWORD(0, 300, 0, 0, RESOURCE);
|
|
|
|
patch KEYWORD(0, 300, 0, 0, PATCH);
|
2013-11-29 21:21:56 +13:00
|
|
|
sample KEYWORD_WITH_ALT(400, 300, 400, 0, yyextra->ARB_gpu_shader5_enable, SAMPLE);
|
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
|
|
|
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;
|
2015-01-20 17:07:13 +01:00
|
|
|
if (state->es_shader && strlen(yytext) > 1024) {
|
|
|
|
_mesa_glsl_error(yylloc, state,
|
|
|
|
"Identifier `%s' exceeds 1024 characters",
|
|
|
|
yytext);
|
|
|
|
} else {
|
|
|
|
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);
|
|
|
|
}
|