Commit graph

22 commits

Author SHA1 Message Date
Kenneth Graunke
7279feeb19 glsl: Add support for the 'u' and 'U' unsigned integer suffixes. 2010-11-15 13:33:58 -08:00
Kenneth Graunke
2b6c1a0b7c glsl: Add new keywords and reserved words for GLSL 1.30. 2010-11-15 13:33:58 -08:00
Kenneth Graunke
285036fbb0 glsl: Rework reserved word/keyword handling in the lexer.
This consolidates the TOKEN_OR_IDENTIFIER and RESERVED_WORD macros into
a single KEYWORD macro.

The old TOKEN_OR_IDENTIFIER macros handled the case of a word going from
an identifier to a keyword; the RESERVED_WORD macro handled a word going
from a reserved word to a language keyword.  However, neither could
properly handle samplerBuffer (for example), which is an identifier in
1.10 and 1.20, a reserved word in 1.30, and a keyword in 1.40 and on.

Furthermore, the existing macros didn't properly handle reserved words
in GLSL ES 1.00.  The best they could do was return a token (rather than
an identifier), resulting in an obtuse parser error, rather than a
user-friendly "you used a reserved word" error message.
2010-11-15 13:33:57 -08:00
Chad Versace
cba9062d58 glsl: Fix lexer rule for ^=
The caret is a special character, and needs to be quoted or escaped.
2010-10-19 13:17:33 -07:00
Chad Versace
7abdc71afa glsl: Add lexer rules for << and >> in GLSL 1.30
Commit for generated file glsl_lexer.cpp follows this commit.
2010-10-15 00:20:18 -07:00
Chad Versace
0c9fef6111 glsl: Add lexer rules for uint and uvecN (N=2..4)
Commit for generated file glsl_lexer.cpp follows this commit.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2010-10-11 14:25:48 -07:00
Ian Romanick
7f68cbdc4d glsl: Add parser support for GL_ARB_explicit_attrib_location layouts
Only layout(location=#) is supported.  Setting the index requires GLSL
1.30 and GL_ARB_blend_func_extended.
2010-10-08 14:21:22 -07:00
Kenneth Graunke
c5e74871d9 glsl: Recognize GLSL ES 1.00 keywords. 2010-09-07 17:30:37 -07:00
Ian Romanick
bea3963f59 glsl2: Parse #pragma lines
All pragmas are currently ignored.  Also, the error messages when a
pragma is used incorrectly (i.e., '#pragma debug(on)' inside a
function) are crap, but I think this is sufficient for now.

Fixes piglit test cases pragma-0[1-8].(vert|frag).
2010-08-30 12:52:42 -07:00
Ian Romanick
5c77efc0b2 glsl2: Avoid token name collisions with names used by Windows header files 2010-08-13 09:30:56 -07:00
Ian Romanick
5b9f3db719 glsl2: Eliminate tokens for square matrix short names
MAT2 and MAT2X2, for example, are treated identically by the parser.
The language version based error checking (becuase mat2x2 is not
available in GLSL 1.10) is already done in the lexer.
2010-08-13 09:29:39 -07:00
Ian Romanick
77215e7e7b glsl2: Emit error from lexer when illegal reserved word is encountered
Without this, the parser will generate obtuse, useless error
diagnostics when reservered word that are not used by the grammar are
encountered in a shader.

Fixes bugzilla #29519.
2010-08-11 17:03:31 -07:00
Kenneth Graunke
b7e63c34e7 glsl2: Add the 1.30 reserved keywords. 2010-08-07 00:51:30 -07:00
Eric Anholt
47f3f22311 glsl2: Add support for floating constants like "1f".
Fixes glsl-floating-constant-120.
2010-08-02 11:26:43 -07:00
Eric Anholt
6a41626e90 glsl2: Make non-square matrix keywords not keywords pre-120.
Fixes glsl-mat-110.
2010-08-01 19:11:10 -07:00
Eric Anholt
192b57df8c glsl2: Make lowp, mediump, highp, and precision identifiers pre-1.20.
Fixes glsl-precision-110.
2010-07-28 17:32:11 -07:00
Ian Romanick
f50f06552e glsl2: Parser support for GL_ARB_fragment_coord_conventions 2010-07-28 14:14:38 -07:00
Eric Anholt
5304493c40 glsl2: Fix lexing of octal values, including "0".
When faced with a constructor like 'ivec4(0, 2, 0, 0)', we would
manage to get a value of 2 instead of 0 for the first "0".  Usually 2
characters past "0" would point at some junk and lex as 0 anyway.

Fixes glsl-octal and glsl-unused-varyings.
2010-07-19 11:58:03 -07:00
Kenneth Graunke
388ab9fa6b glsl2: Initialize yylineno and yycolumn so line numbers are sane. 2010-07-07 12:41:26 -07:00
Ian Romanick
efb6b24223 glsl2: Append _TOK to some parser tokens
This prevents conflicts with defines elsewhere in Mesa and allows
including mtypes.h in the compiler.
2010-07-01 20:40:08 -07:00
Kenneth Graunke
953ff1283d glsl2: Use _mesa_glsl_parse_state as the talloc parent, not glsl_shader.
_mesa_glsl_parse_state should be the parent for all temporary allocation
done while compiling a shader.  glsl_shader should only be used as the
parent for the shader's final IR---the _result_ of compilation.

Since many IR instructions may be added or discarded during optimization
passes, IR should not ever be allocated to glsl_shader directly.

Done via sed -i s/talloc_parent(state)/state/g and s/talloc_parent(st)/st/g.

This also removes a ton of talloc_parent calls, which may help performance.
2010-06-30 13:52:24 -07:00
Eric Anholt
2928588267 glsl2: Move the compiler to the subdirectory it will live in in Mesa. 2010-06-24 15:36:00 -07:00
Renamed from glsl_lexer.lpp (Browse further)