summaryrefslogtreecommitdiff
path: root/src/glsl/glsl_lexer.lpp
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-08-30 11:58:04 -0700
committerIan Romanick <ian.d.romanick@intel.com>2010-08-30 12:52:42 -0700
commitbea3963f59fb8da0687c3e3fbc6f15de8be7fddb (patch)
tree29398e8baec4a2aa397a01b320545cf4ff49f7bd /src/glsl/glsl_lexer.lpp
parent9b0ba68b4489557c48efa088c3884120dabc68fb (diff)
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).
Diffstat (limited to 'src/glsl/glsl_lexer.lpp')
-rw-r--r--src/glsl/glsl_lexer.lpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp
index 3128cdd3a7..1de1fb4cf7 100644
--- a/src/glsl/glsl_lexer.lpp
+++ b/src/glsl/glsl_lexer.lpp
@@ -64,7 +64,7 @@
%option prefix="_mesa_glsl_"
%option extra-type="struct _mesa_glsl_parse_state *"
-%x PP
+%x PP PRAGMA
DEC_INT [1-9][0-9]*
HEX_INT 0[xX][0-9a-fA-F]+
@@ -110,7 +110,27 @@ HASH ^{SPC}#{SPC}
*/
yylineno = strtol(ptr, &ptr, 0) - 1;
}
-^[ \t]*#[ \t]*pragma { BEGIN PP; return PRAGMA; }
+^{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;
+ }
+^{SPC}#{SPC}pragma{SPCP} { BEGIN PRAGMA; }
+
+<PRAGMA>\n { BEGIN 0; yylineno++; yycolumn = 0; }
+<PRAGMA>. { }
+
<PP>\/\/[^\n]* { }
<PP>[ \t\r]* { }
<PP>: return COLON;