2 * Mesa 3-D graphics library
5 * Copyright (C) 2004-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * \file slang_shader.syn
27 * slang vertex/fragment shader syntax
33 * syn2c slang_shader.syn > slang_shader_syn.h
35 * when modifying or extending this file, several things must be taken into
38 * - when adding new operators that were marked as reserved in the
39 * initial specification, one must only uncomment particular lines of
40 * code that refer to operators being added;
42 * - when adding new shader targets, one must reserve a new value for
43 * shader_type register and use it in .if constructs for symbols that
44 * are exclusive for that shader;
46 * - some symbols mimic output of other symbols - the best example is
47 * the "for" construct: expression "for (foo(); ; bar())" is seen as
48 * "for (foo(); true; bar())" by the output processor - hence, special
49 * care must be taken when rearranging output of essential symbols;
51 * - order of single-quoted tokens does matter in alternatives - so do not
52 * parse "<" operator before "<<" and "<<" before "<<=";
54 * - all double-quoted tokens are internally preprocessed to eliminate
55 * problems with parsing strings that are prefixes of other strings,
56 * like "sampler1D" and "sampler1DShadow";
59 .syntax translation_unit;
61 /* revision number - increment after each change affecting emitted output */
64 /* external declaration (or precision or invariant stmt) */
65 .emtcode EXTERNAL_NULL 0
66 .emtcode EXTERNAL_FUNCTION_DEFINITION 1
67 .emtcode EXTERNAL_DECLARATION 2
68 .emtcode DEFAULT_PRECISION 3
69 .emtcode INVARIANT_STMT 4
72 .emtcode PRECISION_DEFAULT 0
73 .emtcode PRECISION_LOW 1
74 .emtcode PRECISION_MEDIUM 2
75 .emtcode PRECISION_HIGH 3
78 .emtcode DECLARATION_FUNCTION_PROTOTYPE 1
79 .emtcode DECLARATION_INIT_DECLARATOR_LIST 2
82 .emtcode FUNCTION_ORDINARY 0
83 .emtcode FUNCTION_CONSTRUCTOR 1
84 .emtcode FUNCTION_OPERATOR 2
87 .emtcode OPERATOR_ADDASSIGN 1
88 .emtcode OPERATOR_SUBASSIGN 2
89 .emtcode OPERATOR_MULASSIGN 3
90 .emtcode OPERATOR_DIVASSIGN 4
91 /*.emtcode OPERATOR_MODASSIGN 5*/
92 /*.emtcode OPERATOR_LSHASSIGN 6*/
93 /*.emtcode OPERATOR_RSHASSIGN 7*/
94 /*.emtcode OPERATOR_ORASSIGN 8*/
95 /*.emtcode OPERATOR_XORASSIGN 9*/
96 /*.emtcode OPERATOR_ANDASSIGN 10*/
97 .emtcode OPERATOR_LOGICALXOR 11
98 /*.emtcode OPERATOR_BITOR 12*/
99 /*.emtcode OPERATOR_BITXOR 13*/
100 /*.emtcode OPERATOR_BITAND 14*/
101 .emtcode OPERATOR_LESS 15
102 .emtcode OPERATOR_GREATER 16
103 .emtcode OPERATOR_LESSEQUAL 17
104 .emtcode OPERATOR_GREATEREQUAL 18
105 /*.emtcode OPERATOR_LSHIFT 19*/
106 /*.emtcode OPERATOR_RSHIFT 20*/
107 .emtcode OPERATOR_MULTIPLY 21
108 .emtcode OPERATOR_DIVIDE 22
109 /*.emtcode OPERATOR_MODULUS 23*/
110 .emtcode OPERATOR_INCREMENT 24
111 .emtcode OPERATOR_DECREMENT 25
112 .emtcode OPERATOR_PLUS 26
113 .emtcode OPERATOR_MINUS 27
114 /*.emtcode OPERATOR_COMPLEMENT 28*/
115 .emtcode OPERATOR_NOT 29
117 /* init declarator list */
118 .emtcode DECLARATOR_NONE 0
119 .emtcode DECLARATOR_NEXT 1
121 /* variable declaration */
122 .emtcode VARIABLE_NONE 0
123 .emtcode VARIABLE_IDENTIFIER 1
124 .emtcode VARIABLE_INITIALIZER 2
125 .emtcode VARIABLE_ARRAY_EXPLICIT 3
126 .emtcode VARIABLE_ARRAY_UNKNOWN 4
129 .emtcode TYPE_QUALIFIER_NONE 0
130 .emtcode TYPE_QUALIFIER_CONST 1
131 .emtcode TYPE_QUALIFIER_ATTRIBUTE 2
132 .emtcode TYPE_QUALIFIER_VARYING 3
133 .emtcode TYPE_QUALIFIER_UNIFORM 4
134 .emtcode TYPE_QUALIFIER_FIXEDOUTPUT 5
135 .emtcode TYPE_QUALIFIER_FIXEDINPUT 6
137 /* invariant qualifier */
138 .emtcode TYPE_VARIANT 90
139 .emtcode TYPE_INVARIANT 91
141 /* centroid qualifier */
142 .emtcode TYPE_CENTER 95
143 .emtcode TYPE_CENTROID 96
146 .emtcode TYPE_SPECIFIER_VOID 0
147 .emtcode TYPE_SPECIFIER_BOOL 1
148 .emtcode TYPE_SPECIFIER_BVEC2 2
149 .emtcode TYPE_SPECIFIER_BVEC3 3
150 .emtcode TYPE_SPECIFIER_BVEC4 4
151 .emtcode TYPE_SPECIFIER_INT 5
152 .emtcode TYPE_SPECIFIER_IVEC2 6
153 .emtcode TYPE_SPECIFIER_IVEC3 7
154 .emtcode TYPE_SPECIFIER_IVEC4 8
155 .emtcode TYPE_SPECIFIER_FLOAT 9
156 .emtcode TYPE_SPECIFIER_VEC2 10
157 .emtcode TYPE_SPECIFIER_VEC3 11
158 .emtcode TYPE_SPECIFIER_VEC4 12
159 .emtcode TYPE_SPECIFIER_MAT2 13
160 .emtcode TYPE_SPECIFIER_MAT3 14
161 .emtcode TYPE_SPECIFIER_MAT4 15
162 .emtcode TYPE_SPECIFIER_SAMPLER1D 16
163 .emtcode TYPE_SPECIFIER_SAMPLER2D 17
164 .emtcode TYPE_SPECIFIER_SAMPLER3D 18
165 .emtcode TYPE_SPECIFIER_SAMPLERCUBE 19
166 .emtcode TYPE_SPECIFIER_SAMPLER1DSHADOW 20
167 .emtcode TYPE_SPECIFIER_SAMPLER2DSHADOW 21
168 .emtcode TYPE_SPECIFIER_SAMPLER2DRECT 22
169 .emtcode TYPE_SPECIFIER_SAMPLER2DRECTSHADOW 23
170 .emtcode TYPE_SPECIFIER_STRUCT 24
171 .emtcode TYPE_SPECIFIER_TYPENAME 25
174 .emtcode TYPE_SPECIFIER_MAT23 26
175 .emtcode TYPE_SPECIFIER_MAT32 27
176 .emtcode TYPE_SPECIFIER_MAT24 28
177 .emtcode TYPE_SPECIFIER_MAT42 29
178 .emtcode TYPE_SPECIFIER_MAT34 30
179 .emtcode TYPE_SPECIFIER_MAT43 31
182 /* structure field */
183 .emtcode FIELD_NONE 0
184 .emtcode FIELD_NEXT 1
185 .emtcode FIELD_ARRAY 2
189 .emtcode OP_BLOCK_BEGIN_NO_NEW_SCOPE 1
190 .emtcode OP_BLOCK_BEGIN_NEW_SCOPE 2
191 .emtcode OP_DECLARE 3
194 .emtcode OP_CONTINUE 6
195 .emtcode OP_DISCARD 7
197 .emtcode OP_EXPRESSION 9
202 .emtcode OP_PUSH_VOID 14
203 .emtcode OP_PUSH_BOOL 15
204 .emtcode OP_PUSH_INT 16
205 .emtcode OP_PUSH_FLOAT 17
206 .emtcode OP_PUSH_IDENTIFIER 18
207 .emtcode OP_SEQUENCE 19
208 .emtcode OP_ASSIGN 20
209 .emtcode OP_ADDASSIGN 21
210 .emtcode OP_SUBASSIGN 22
211 .emtcode OP_MULASSIGN 23
212 .emtcode OP_DIVASSIGN 24
213 /*.emtcode OP_MODASSIGN 25*/
214 /*.emtcode OP_LSHASSIGN 26*/
215 /*.emtcode OP_RSHASSIGN 27*/
216 /*.emtcode OP_ORASSIGN 28*/
217 /*.emtcode OP_XORASSIGN 29*/
218 /*.emtcode OP_ANDASSIGN 30*/
219 .emtcode OP_SELECT 31
220 .emtcode OP_LOGICALOR 32
221 .emtcode OP_LOGICALXOR 33
222 .emtcode OP_LOGICALAND 34
223 /*.emtcode OP_BITOR 35*/
224 /*.emtcode OP_BITXOR 36*/
225 /*.emtcode OP_BITAND 37*/
227 .emtcode OP_NOTEQUAL 39
229 .emtcode OP_GREATER 41
230 .emtcode OP_LESSEQUAL 42
231 .emtcode OP_GREATEREQUAL 43
232 /*.emtcode OP_LSHIFT 44*/
233 /*.emtcode OP_RSHIFT 45*/
235 .emtcode OP_SUBTRACT 47
236 .emtcode OP_MULTIPLY 48
237 .emtcode OP_DIVIDE 49
238 /*.emtcode OP_MODULUS 50*/
239 .emtcode OP_PREINCREMENT 51
240 .emtcode OP_PREDECREMENT 52
243 /*.emtcode OP_COMPLEMENT 55*/
245 .emtcode OP_SUBSCRIPT 57
248 .emtcode OP_POSTINCREMENT 60
249 .emtcode OP_POSTDECREMENT 61
250 .emtcode OP_PRECISION 62
252 /* parameter qualifier */
253 .emtcode PARAM_QUALIFIER_IN 0
254 .emtcode PARAM_QUALIFIER_OUT 1
255 .emtcode PARAM_QUALIFIER_INOUT 2
257 /* function parameter */
258 .emtcode PARAMETER_NONE 0
259 .emtcode PARAMETER_NEXT 1
261 /* function parameter array presence */
262 .emtcode PARAMETER_ARRAY_NOT_PRESENT 0
263 .emtcode PARAMETER_ARRAY_PRESENT 1
265 /* INVALID_EXTERNAL_DECLARATION seems to be reported when there's */
266 /* any syntax errors... */
267 .errtext INVALID_EXTERNAL_DECLARATION "2001: Syntax error."
268 .errtext INVALID_OPERATOR_OVERRIDE "2002: Invalid operator override."
269 .errtext LBRACE_EXPECTED "2003: '{' expected but '$err_token$' found."
270 .errtext LPAREN_EXPECTED "2004: '(' expected but '$err_token$' found."
271 .errtext RPAREN_EXPECTED "2005: ')' expected but '$err_token$' found."
272 .errtext INVALID_PRECISION "2006: Invalid precision specifier '$err_token$'."
273 .errtext INVALID_PRECISION_TYPE "2007: Invalid precision type '$err_token$'."
277 * tells whether the shader that is being parsed is a built-in shader or not
278 * 0 - normal behaviour
279 * 1 - accepts constructor and operator definitions and __asm statements
280 * the implementation will set it to 1 when compiling internal built-in shaders
282 .regbyte parsing_builtin 0
285 * holds the type of the shader being parsed; possible values are
289 * shader type is set by the caller before parsing
291 .regbyte shader_type 0
294 * <variable_identifier> ::= <identifier>
297 identifier .emit OP_PUSH_IDENTIFIER;
300 * <primary_expression> ::= <variable_identifier>
304 * | "(" <expression> ")"
307 floatconstant .or boolconstant .or intconstant .or variable_identifier .or primary_expression_1;
309 lparen .and expression .and rparen;
312 * <postfix_expression> ::= <primary_expression>
313 * | <postfix_expression> "[" <integer_expression> "]"
315 * | <postfix_expression> "." <field_selection>
316 * | <postfix_expression> "++"
317 * | <postfix_expression> "--"
320 postfix_expression_1 .and .loop postfix_expression_2;
322 function_call .or primary_expression;
324 postfix_expression_3 .or postfix_expression_4 .or
325 plusplus .emit OP_POSTINCREMENT .or
326 minusminus .emit OP_POSTDECREMENT;
328 lbracket .and integer_expression .and rbracket .emit OP_SUBSCRIPT;
330 dot .and field_selection .emit OP_FIELD;
333 * <integer_expression> ::= <expression>
339 * <function_call> ::= <function_call_generic>
342 function_call_generic .emit OP_CALL .and .true .emit OP_END;
345 * <function_call_generic> ::= <function_call_header_with_parameters> ")"
346 * | <function_call_header_no_parameters> ")"
348 function_call_generic
349 function_call_generic_1 .or function_call_generic_2;
350 function_call_generic_1
351 function_call_header_with_parameters .and rparen .error RPAREN_EXPECTED;
352 function_call_generic_2
353 function_call_header_no_parameters .and rparen .error RPAREN_EXPECTED;
356 * <function_call_header_no_parameters>::= <function_call_header> "void"
357 * | <function_call_header>
359 function_call_header_no_parameters
360 function_call_header .and function_call_header_no_parameters_1;
361 function_call_header_no_parameters_1
365 * <function_call_header_with_parameters> ::= <function_call_header> <assignment_expression>
366 * | <function_call_header_with_parameters> "," <assignment_expression>
368 function_call_header_with_parameters
369 function_call_header .and assignment_expression .and .true .emit OP_END .and
370 .loop function_call_header_with_parameters_1;
371 function_call_header_with_parameters_1
372 comma .and assignment_expression .and .true .emit OP_END;
375 * <function_call_header> ::= <function_identifier> "("
378 function_identifier .and lparen;
381 * <function_identifier> ::= <constructor_identifier>
384 * note: <constructor_identifier> has been deleted
390 * <unary_expression> ::= <postfix_expression>
391 * | "++" <unary_expression>
392 * | "--" <unary_expression>
393 * | <unary_operator> <unary_expression>
395 * <unary_operator> ::= "+"
401 postfix_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or
402 unary_expression_4 .or unary_expression_5/* .or unary_expression_6*/;
404 plusplus .and unary_expression .and .true .emit OP_PREINCREMENT;
406 minusminus .and unary_expression .and .true .emit OP_PREDECREMENT;
408 plus .and unary_expression .and .true .emit OP_PLUS;
410 minus .and unary_expression .and .true .emit OP_MINUS;
412 bang .and unary_expression .and .true .emit OP_NOT;
414 tilde .and unary_expression .and .true .emit OP_COMPLEMENT;*/
417 * <multiplicative_expression> ::= <unary_expression>
418 * | <multiplicative_expression> "*" <unary_expression>
419 * | <multiplicative_expression> "/" <unary_expression>
420 * | <multiplicative_expression> "%" <unary_expression> // reserved
422 multiplicative_expression
423 unary_expression .and .loop multiplicative_expression_1;
424 multiplicative_expression_1
425 multiplicative_expression_2 .or multiplicative_expression_3/* .or multiplicative_expression_4*/;
426 multiplicative_expression_2
427 star .and unary_expression .and .true .emit OP_MULTIPLY;
428 multiplicative_expression_3
429 slash .and unary_expression .and .true .emit OP_DIVIDE;
430 /*multiplicative_expression_4
431 percent .and unary_expression .and .true .emit OP_MODULUS;*/
434 * <additive_expression> ::= <multiplicative_expression>
435 * | <additive_expression> "+" <multiplicative_expression>
436 * | <additive_expression> "-" <multiplicative_expression>
439 multiplicative_expression .and .loop additive_expression_1;
440 additive_expression_1
441 additive_expression_2 .or additive_expression_3;
442 additive_expression_2
443 plus .and multiplicative_expression .and .true .emit OP_ADD;
444 additive_expression_3
445 minus .and multiplicative_expression .and .true .emit OP_SUBTRACT;
448 * <shift_expression> ::= <additive_expression>
449 * | <shift_expression> "<<" <additive_expression> // reserved
450 * | <shift_expression> ">>" <additive_expression> // reserved
453 additive_expression/* .and .loop shift_expression_1*/;
455 shift_expression_2 .or shift_expression_3;*/
457 lessless .and additive_expression .and .true .emit OP_LSHIFT;*/
459 greatergreater .and additive_expression .and .true .emit OP_RSHIFT;*/
462 * <relational_expression> ::= <shift_expression>
463 * | <relational_expression> "<" <shift_expression>
464 * | <relational_expression> ">" <shift_expression>
465 * | <relational_expression> "<=" <shift_expression>
466 * | <relational_expression> ">=" <shift_expression>
468 relational_expression
469 shift_expression .and .loop relational_expression_1;
470 relational_expression_1
471 relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or
472 relational_expression_5;
473 relational_expression_2
474 lessequals .and shift_expression .and .true .emit OP_LESSEQUAL;
475 relational_expression_3
476 greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL;
477 relational_expression_4
478 less .and shift_expression .and .true .emit OP_LESS;
479 relational_expression_5
480 greater .and shift_expression .and .true .emit OP_GREATER;
483 * <equality_expression> ::= <relational_expression>
484 * | <equality_expression> "==" <relational_expression>
485 * | <equality_expression> "!=" <relational_expression>
488 relational_expression .and .loop equality_expression_1;
489 equality_expression_1
490 equality_expression_2 .or equality_expression_3;
491 equality_expression_2
492 equalsequals .and relational_expression .and .true .emit OP_EQUAL;
493 equality_expression_3
494 bangequals .and relational_expression .and .true .emit OP_NOTEQUAL;
497 * <and_expression> ::= <equality_expression>
498 * | <and_expression> "&" <equality_expression> // reserved
501 equality_expression/* .and .loop and_expression_1*/;
503 ampersand .and equality_expression .and .true .emit OP_BITAND;*/
506 * <exclusive_or_expression> ::= <and_expression>
507 * | <exclusive_or_expression> "^" <and_expression> // reserved
509 exclusive_or_expression
510 and_expression/* .and .loop exclusive_or_expression_1*/;
511 /*exclusive_or_expression_1
512 caret .and and_expression .and .true .emit OP_BITXOR;*/
515 * <inclusive_or_expression> ::= <exclusive_or_expression>
516 * | <inclusive_or_expression> "|" <exclusive_or_expression> // reserved
518 inclusive_or_expression
519 exclusive_or_expression/* .and .loop inclusive_or_expression_1*/;
520 /*inclusive_or_expression_1
521 bar .and exclusive_or_expression .and .true .emit OP_BITOR;*/
524 * <logical_and_expression> ::= <inclusive_or_expression>
525 * | <logical_and_expression> "&&" <inclusive_or_expression>
527 logical_and_expression
528 inclusive_or_expression .and .loop logical_and_expression_1;
529 logical_and_expression_1
530 ampersandampersand .and inclusive_or_expression .and .true .emit OP_LOGICALAND;
533 * <logical_xor_expression> ::= <logical_and_expression>
534 * | <logical_xor_expression> "^^" <logical_and_expression>
536 logical_xor_expression
537 logical_and_expression .and .loop logical_xor_expression_1;
538 logical_xor_expression_1
539 caretcaret .and logical_and_expression .and .true .emit OP_LOGICALXOR;
542 * <logical_or_expression> ::= <logical_xor_expression>
543 * | <logical_or_expression> "||" <logical_xor_expression>
545 logical_or_expression
546 logical_xor_expression .and .loop logical_or_expression_1;
547 logical_or_expression_1
548 barbar .and logical_xor_expression .and .true .emit OP_LOGICALOR;
551 * <conditional_expression> ::= <logical_or_expression>
552 * | <logical_or_expression> "?" <expression> ":" <conditional_expression>
554 conditional_expression
555 logical_or_expression .and .loop conditional_expression_1;
556 conditional_expression_1
557 question .and expression .and colon .and conditional_expression .and .true .emit OP_SELECT;
560 * <assignment_expression> ::= <conditional_expression>
561 * | <unary_expression> <assignment_operator> <assignment_expression>
563 * <assignment_operator> ::= "="
569 * | "<<=" // reserved
570 * | ">>=" // reserved
575 assignment_expression
576 assignment_expression_1 .or assignment_expression_2 .or assignment_expression_3 .or
577 assignment_expression_4 .or assignment_expression_5/* .or assignment_expression_6 .or
578 assignment_expression_7 .or assignment_expression_8 .or assignment_expression_9 .or
579 assignment_expression_10 .or assignment_expression_11*/ .or conditional_expression;
580 assignment_expression_1
581 unary_expression .and equals .and assignment_expression .and .true .emit OP_ASSIGN;
582 assignment_expression_2
583 unary_expression .and starequals .and assignment_expression .and .true .emit OP_MULASSIGN;
584 assignment_expression_3
585 unary_expression .and slashequals .and assignment_expression .and .true .emit OP_DIVASSIGN;
586 assignment_expression_4
587 unary_expression .and plusequals .and assignment_expression .and .true .emit OP_ADDASSIGN;
588 assignment_expression_5
589 unary_expression .and minusequals .and assignment_expression .and .true .emit OP_SUBASSIGN;
590 /*assignment_expression_6
591 unary_expression .and percentequals .and assignment_expression .and .true .emit OP_MODASSIGN;*/
592 /*assignment_expression_7
593 unary_expression .and lesslessequals .and assignment_expression .and .true .emit OP_LSHASSIGN;*/
594 /*assignment_expression_8
595 unary_expression .and greatergreaterequals .and assignment_expression .and
596 .true .emit OP_RSHASSIGN;*/
597 /*assignment_expression_9
598 unary_expression .and ampersandequals .and assignment_expression .and .true .emit OP_ANDASSIGN;*/
599 /*assignment_expression_10
600 unary_expression .and caretequals .and assignment_expression .and .true .emit OP_XORASSIGN;*/
601 /*assignment_expression_11
602 unary_expression .and barequals .and assignment_expression .and .true .emit OP_ORASSIGN;*/
605 * <expression> ::= <assignment_expression>
606 * | <expression> "," <assignment_expression>
609 assignment_expression .and .loop expression_1;
611 comma .and assignment_expression .and .true .emit OP_SEQUENCE;
614 * <constant_expression> ::= <conditional_expression>
617 conditional_expression .and .true .emit OP_END;
620 * <declaration> ::= <function_prototype> ";"
621 * | <init_declarator_list> ";"
624 declaration_1 .or declaration_2;
626 function_prototype .emit DECLARATION_FUNCTION_PROTOTYPE .and semicolon;
628 init_declarator_list .emit DECLARATION_INIT_DECLARATOR_LIST .and semicolon;
631 * <function_prototype> ::= <function_header> "void" ")"
632 * | <function_declarator> ")"
635 function_prototype_1 .or function_prototype_2;
637 function_header .and "void" .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;
639 function_declarator .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;
642 * <function_declarator> ::= <function_header>
643 * | <function_header_with_parameters>
646 function_header_with_parameters .or function_header;
649 * <function_header_with_parameters> ::= <function_header> <parameter_declaration>
650 * | <function_header_with_parameters> ","
651 * <parameter_declaration>
653 function_header_with_parameters
654 function_header .and parameter_declaration .and .loop function_header_with_parameters_1;
655 function_header_with_parameters_1
656 comma .and parameter_declaration;
659 * <function_header> ::= <fully_specified_type> <identifier> "("
662 function_header_nospace .or function_header_space;
663 function_header_space
664 fully_specified_type_space .and space .and function_decl_identifier .and lparen;
665 function_header_nospace
666 fully_specified_type_nospace .and function_decl_identifier .and lparen;
669 * <function_decl_identifier> ::= "__constructor"
673 * note: this is an extension to the standard language specification.
674 * normally slang disallows operator and constructor prototypes and definitions
676 function_decl_identifier
677 .if (parsing_builtin != 0) __operator .emit FUNCTION_OPERATOR .or
678 .if (parsing_builtin != 0) "__constructor" .emit FUNCTION_CONSTRUCTOR .or
679 identifier .emit FUNCTION_ORDINARY;
682 * <__operator> ::= "__operator" <overriden_op>
684 * note: this is an extension to the standard language specification.
685 * normally slang disallows operator prototypes and definitions
688 "__operator" .and overriden_operator .error INVALID_OPERATOR_OVERRIDE;
691 * <overriden_op> ::= "="
697 * | "<<=" // reserved
698 * | ">>=" // reserved
724 * note: this is an extension to the standard language specification.
725 * normally slang disallows operator prototypes and definitions
728 plusplus .emit OPERATOR_INCREMENT .or
729 plusequals .emit OPERATOR_ADDASSIGN .or
730 plus .emit OPERATOR_PLUS .or
731 minusminus .emit OPERATOR_DECREMENT .or
732 minusequals .emit OPERATOR_SUBASSIGN .or
733 minus .emit OPERATOR_MINUS .or
734 bang .emit OPERATOR_NOT .or
735 starequals .emit OPERATOR_MULASSIGN .or
736 star .emit OPERATOR_MULTIPLY .or
737 slashequals .emit OPERATOR_DIVASSIGN .or
738 slash .emit OPERATOR_DIVIDE .or
739 lessequals .emit OPERATOR_LESSEQUAL .or
740 /*lesslessequals .emit OPERATOR_LSHASSIGN .or*/
741 /*lessless .emit OPERATOR_LSHIFT .or*/
742 less .emit OPERATOR_LESS .or
743 greaterequals .emit OPERATOR_GREATEREQUAL .or
744 /*greatergreaterequals .emit OPERATOR_RSHASSIGN .or*/
745 /*greatergreater .emit OPERATOR_RSHIFT .or*/
746 greater .emit OPERATOR_GREATER .or
747 /*percentequals .emit OPERATOR_MODASSIGN .or*/
748 /*percent .emit OPERATOR_MODULUS .or*/
749 /*ampersandequals .emit OPERATOR_ANDASSIGN */
750 /*ampersand .emit OPERATOR_BITAND .or*/
751 /*barequals .emit OPERATOR_ORASSIGN .or*/
752 /*bar .emit OPERATOR_BITOR .or*/
753 /*tilde .emit OPERATOR_COMPLEMENT .or*/
754 /*caretequals .emit OPERATOR_XORASSIGN .or*/
755 caretcaret .emit OPERATOR_LOGICALXOR /*.or
756 caret .emit OPERATOR_BITXOR*/;
759 * <parameter_declarator> ::= <type_specifier> <identifier>
760 * | <type_specifier> <identifier> "[" <constant_expression> "]"
763 parameter_declarator_nospace .or parameter_declarator_space;
764 parameter_declarator_nospace
765 type_specifier_nospace .and identifier .and parameter_declarator_1;
766 parameter_declarator_space
767 type_specifier_space .and space .and identifier .and parameter_declarator_1;
768 parameter_declarator_1
769 parameter_declarator_2 .emit PARAMETER_ARRAY_PRESENT .or
770 .true .emit PARAMETER_ARRAY_NOT_PRESENT;
771 parameter_declarator_2
772 lbracket .and constant_expression .and rbracket;
775 * <parameter_declaration> ::= <type_qualifier> <parameter_qualifier>
776 * <precision> <parameter_declarator>
777 * | <type_qualifier> <parameter_qualifier>
778 * <precision> <parameter_type_specifier>
779 * | <type_qualifier> <parameter_qualifier>
780 * <parameter_declarator>
781 * | <type_qualifier> <parameter_qualifier>
782 * <parameter_type_specifier>
783 * | <parameter_qualifier> <precision>
784 * <parameter_declarator>
785 * | <parameter_qualifier> <precision>
786 * <parameter_type_specifier>
787 * | <parameter_qualifier> <parameter_declarator>
788 * | <parameter_qualifier> <parameter_type_specifier>
790 parameter_declaration
791 parameter_declaration_1 .emit PARAMETER_NEXT;
792 parameter_declaration_1
793 parameter_declaration_2 .or parameter_declaration_3;
794 parameter_declaration_2
795 type_qualifier .and space .and parameter_qualifier .and parameter_declaration_4;
796 parameter_declaration_3
797 parameter_qualifier .emit TYPE_QUALIFIER_NONE .and parameter_declaration_4;
798 parameter_declaration_4
799 parameter_declaration_optprec .and parameter_declaration_rest;
800 parameter_declaration_optprec
801 parameter_declaration_prec .or .true .emit PRECISION_DEFAULT;
802 parameter_declaration_prec
803 precision .and space;
804 parameter_declaration_rest
805 parameter_declarator .or parameter_type_specifier;
808 * <parameter_qualifier> ::= "in"
814 parameter_qualifier_1 .or .true .emit PARAM_QUALIFIER_IN;
815 parameter_qualifier_1
816 parameter_qualifier_2 .and space;
817 parameter_qualifier_2
818 "in" .emit PARAM_QUALIFIER_IN .or
819 "out" .emit PARAM_QUALIFIER_OUT .or
820 "inout" .emit PARAM_QUALIFIER_INOUT;
823 * <parameter_type_specifier> ::= <type_specifier>
824 * | <type_specifier> "[" <constant_expression> "]"
826 parameter_type_specifier
827 parameter_type_specifier_1 .and .true .emit '\0' .and parameter_type_specifier_2;
828 parameter_type_specifier_1
829 type_specifier_nospace .or type_specifier_space;
830 parameter_type_specifier_2
831 parameter_type_specifier_3 .emit PARAMETER_ARRAY_PRESENT .or
832 .true .emit PARAMETER_ARRAY_NOT_PRESENT;
833 parameter_type_specifier_3
834 lbracket .and constant_expression .and rbracket;
837 * <init_declarator_list> ::= <single_declaration>
838 * | <init_declarator_list> "," <identifier>
839 * | <init_declarator_list> "," <identifier> "[" "]"
840 * | <init_declarator_list> "," <identifier> "[" <constant_expression> "]"
841 * | <init_declarator_list> "," <identifier> "=" <initializer>
844 single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and
845 .true .emit DECLARATOR_NONE;
846 init_declarator_list_1
847 comma .and identifier .emit VARIABLE_IDENTIFIER .and init_declarator_list_2;
848 init_declarator_list_2
849 init_declarator_list_3 .or init_declarator_list_4 .or .true .emit VARIABLE_NONE;
850 init_declarator_list_3
851 equals .and initializer .emit VARIABLE_INITIALIZER;
852 init_declarator_list_4
853 lbracket .and init_declarator_list_5 .and rbracket;
854 init_declarator_list_5
855 constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
858 * <single_declaration> ::= <fully_specified_type>
859 * | <fully_specified_type> <identifier>
860 * | <fully_specified_type> <identifier> "[" "]"
861 * | <fully_specified_type> <identifier> "[" <constant_expression> "]"
862 * | <fully_specified_type> <identifier> "=" <initializer>
865 single_declaration_nospace .or single_declaration_space;
866 single_declaration_space
867 fully_specified_type_space .and single_declaration_space_1;
868 single_declaration_nospace
869 fully_specified_type_nospace .and single_declaration_nospace_1;
870 single_declaration_space_1
871 single_declaration_space_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
872 single_declaration_nospace_1
873 single_declaration_nospace_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
874 single_declaration_space_2
875 space .and identifier .and single_declaration_3;
876 single_declaration_nospace_2
877 identifier .and single_declaration_3;
879 single_declaration_4 .or single_declaration_5 .or .true .emit VARIABLE_NONE;
881 equals .and initializer .emit VARIABLE_INITIALIZER;
883 lbracket .and single_declaration_6 .and rbracket;
885 constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
888 * <fully_specified_type> ::= <opt_invariant> <opt_centroid> <opt_qualifer> <opt_precision> <type_specifier>
890 * Example: "invariant varying highp vec3"
892 fully_specified_type_space
893 fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;
894 fully_specified_type_nospace
895 fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;
896 fully_specified_type_optinvariant
897 fully_specified_type_invariant .or .true .emit TYPE_VARIANT;
898 fully_specified_type_invariant
899 invariant_qualifier .and space;
900 fully_specified_type_optcentroid
901 fully_specified_type_centroid .or .true .emit TYPE_CENTER;
902 fully_specified_type_centroid
903 centroid_qualifier .and space;
904 fully_specified_type_optqual
905 fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;
906 fully_specified_type_qual
907 type_qualifier .and space;
908 fully_specified_type_optprec
909 fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;
910 fully_specified_type_prec
911 precision .and space;
914 * <invariant_qualifier> ::= "invariant"
917 "invariant" .emit TYPE_INVARIANT;
920 "centroid" .emit TYPE_CENTROID;
924 * <type_qualifier> ::= "const"
925 * | "attribute" // Vertex only.
931 * note: this is an extension to the standard language specification,
932 * normally slang disallows __fixed_output and __fixed_input type qualifiers
935 "const" .emit TYPE_QUALIFIER_CONST .or
936 .if (shader_type == 2) "attribute" .emit TYPE_QUALIFIER_ATTRIBUTE .or
937 "varying" .emit TYPE_QUALIFIER_VARYING .or
938 "uniform" .emit TYPE_QUALIFIER_UNIFORM .or
939 .if (parsing_builtin != 0) "__fixed_output" .emit TYPE_QUALIFIER_FIXEDOUTPUT .or
940 .if (parsing_builtin != 0) "__fixed_input" .emit TYPE_QUALIFIER_FIXEDINPUT;
943 * <type_specifier> ::= "void"
969 * | "sampler1DShadow"
970 * | "sampler2DShadow"
972 * | "sampler2DRectShadow"
973 * | <struct_specifier>
977 "void" .emit TYPE_SPECIFIER_VOID .or
978 "float" .emit TYPE_SPECIFIER_FLOAT .or
979 "int" .emit TYPE_SPECIFIER_INT .or
980 "bool" .emit TYPE_SPECIFIER_BOOL .or
981 "vec2" .emit TYPE_SPECIFIER_VEC2 .or
982 "vec3" .emit TYPE_SPECIFIER_VEC3 .or
983 "vec4" .emit TYPE_SPECIFIER_VEC4 .or
984 "bvec2" .emit TYPE_SPECIFIER_BVEC2 .or
985 "bvec3" .emit TYPE_SPECIFIER_BVEC3 .or
986 "bvec4" .emit TYPE_SPECIFIER_BVEC4 .or
987 "ivec2" .emit TYPE_SPECIFIER_IVEC2 .or
988 "ivec3" .emit TYPE_SPECIFIER_IVEC3 .or
989 "ivec4" .emit TYPE_SPECIFIER_IVEC4 .or
990 "mat2" .emit TYPE_SPECIFIER_MAT2 .or
991 "mat3" .emit TYPE_SPECIFIER_MAT3 .or
992 "mat4" .emit TYPE_SPECIFIER_MAT4 .or
993 "mat2x3" .emit TYPE_SPECIFIER_MAT23 .or
994 "mat3x2" .emit TYPE_SPECIFIER_MAT32 .or
995 "mat2x4" .emit TYPE_SPECIFIER_MAT24 .or
996 "mat4x2" .emit TYPE_SPECIFIER_MAT42 .or
997 "mat3x4" .emit TYPE_SPECIFIER_MAT34 .or
998 "mat4x3" .emit TYPE_SPECIFIER_MAT43 .or
999 "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
1000 "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
1001 "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
1002 "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
1003 "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
1004 "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
1005 "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
1006 "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or
1007 type_name .emit TYPE_SPECIFIER_TYPENAME;
1008 type_specifier_nospace
1009 struct_specifier .emit TYPE_SPECIFIER_STRUCT;
1012 * <struct_specifier> ::= "struct" <identifier> "{" <struct_declaration_list> "}"
1013 * | "struct" "{" <struct_declaration_list> "}"
1016 "struct" .and struct_specifier_1 .and optional_space .and lbrace .error LBRACE_EXPECTED .and
1017 struct_declaration_list .and rbrace .emit FIELD_NONE;
1019 struct_specifier_2 .or .true .emit '\0';
1021 space .and identifier;
1024 * <struct_declaration_list> ::= <struct_declaration>
1025 * | <struct_declaration_list> <struct_declaration>
1027 struct_declaration_list
1028 struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;
1031 * <struct_declaration> ::= <type_specifier> <struct_declarator_list> ";"
1034 struct_declaration_nospace .or struct_declaration_space;
1035 struct_declaration_space
1036 type_specifier_space .and space .and struct_declarator_list .and semicolon .emit FIELD_NONE;
1037 struct_declaration_nospace
1038 type_specifier_nospace .and struct_declarator_list .and semicolon .emit FIELD_NONE;
1041 * <struct_declarator_list> ::= <struct_declarator>
1042 * | <struct_declarator_list> "," <struct_declarator>
1044 struct_declarator_list
1045 struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT;
1046 struct_declarator_list_1
1047 comma .and struct_declarator;
1050 * <struct_declarator> ::= <identifier>
1051 * | <identifier> "[" <constant_expression> "]"
1054 identifier .and struct_declarator_1;
1056 struct_declarator_2 .emit FIELD_ARRAY .or .true .emit FIELD_NONE;
1058 lbracket .and constant_expression .and rbracket;
1061 * <initializer> ::= <assignment_expression>
1064 assignment_expression .and .true .emit OP_END;
1067 * <declaration_statement> ::= <declaration>
1069 declaration_statement
1073 * <statement> ::= <compound_statement>
1074 * | <simple_statement>
1077 compound_statement .or simple_statement;
1079 compound_statement .or statement_space_1;
1081 space .and simple_statement;
1084 * <simple_statement> ::= <__asm_statement>
1085 * | <selection_statement>
1086 * | <iteration_statement>
1087 * | <jump_statement>
1088 * | <expression_statement>
1089 * | <declaration_statement>
1091 * note: this is an extension to the standard language specification.
1092 * normally slang disallows use of __asm statements
1095 .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or
1096 selection_statement .or
1097 iteration_statement .or
1098 precision_stmt .emit OP_PRECISION .or
1100 expression_statement .emit OP_EXPRESSION .or
1101 declaration_statement .emit OP_DECLARE;
1104 * <compound_statement> ::= "{" "}"
1105 * | "{" <statement_list> "}"
1108 compound_statement_1 .emit OP_BLOCK_BEGIN_NEW_SCOPE .and .true .emit OP_END;
1109 compound_statement_1
1110 compound_statement_2 .or compound_statement_3;
1111 compound_statement_2
1113 compound_statement_3
1114 lbrace .and statement_list .and rbrace;
1117 * <statement_no_new_scope> ::= <compound_statement_no_new_scope>
1118 * | <simple_statement>
1120 statement_no_new_scope
1121 compound_statement_no_new_scope .or simple_statement;
1124 * <compound_statement_no_new_scope> ::= "{" "}"
1125 * | "{" <statement_list> "}"
1127 compound_statement_no_new_scope
1128 compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;
1129 compound_statement_no_new_scope_1
1130 compound_statement_no_new_scope_2 .or compound_statement_no_new_scope_3;
1131 compound_statement_no_new_scope_2
1133 compound_statement_no_new_scope_3
1134 lbrace .and statement_list .and rbrace;
1137 * <statement_list> ::= <statement>
1138 * | <statement_list> <statement>
1141 statement .and .loop statement;
1144 * <expression_statement> ::= ";"
1145 * | <expression> ";"
1147 expression_statement
1148 expression_statement_1 .or expression_statement_2;
1149 expression_statement_1
1150 semicolon .emit OP_PUSH_VOID .emit OP_END;
1151 expression_statement_2
1152 expression .and semicolon .emit OP_END;
1155 * <selection_statement> ::= "if" "(" <expression> ")" <selection_rest_statement>
1158 "if" .emit OP_IF .and lparen .error LPAREN_EXPECTED .and expression .and
1159 rparen .error RPAREN_EXPECTED .emit OP_END .and selection_rest_statement;
1162 * <selection_rest_statement> ::= <statement> "else" <statement>
1165 selection_rest_statement
1166 statement .and selection_rest_statement_1;
1167 selection_rest_statement_1
1168 selection_rest_statement_2 .or .true .emit OP_EXPRESSION .emit OP_PUSH_VOID .emit OP_END;
1169 selection_rest_statement_2
1170 "else" .and optional_space .and statement;
1173 * <condition> ::= <expression>
1174 * | <fully_specified_type> <identifier> "=" <initializer>
1176 * note: if <condition_1> is executed, the emit format must
1177 * match <declaration> emit format
1180 condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or
1181 condition_3 .emit OP_EXPRESSION;
1183 condition_1_nospace .or condition_1_space;
1185 fully_specified_type_nospace .and condition_2;
1187 fully_specified_type_space .and space .and condition_2;
1189 identifier .emit VARIABLE_IDENTIFIER .and equals .emit VARIABLE_INITIALIZER .and
1190 initializer .and .true .emit DECLARATOR_NONE;
1192 expression .and .true .emit OP_END;
1195 * <iteration_statement> ::= "while" "(" <condition> ")" <statement>
1196 * | "do" <statement> "while" "(" <expression> ")" ";"
1197 * | "for" "(" <for_init_statement> <for_rest_statement> ")"
1198 * <statement_no_new_scope>
1201 iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;
1202 iteration_statement_1
1203 "while" .emit OP_WHILE .and lparen .error LPAREN_EXPECTED .and condition .and
1204 rparen .error RPAREN_EXPECTED .and statement;
1205 iteration_statement_2
1206 "do" .emit OP_DO .and statement_space .and "while" .and lparen .error LPAREN_EXPECTED .and
1207 expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;
1208 iteration_statement_3
1209 "for" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and
1210 for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement_no_new_scope;
1213 * <for_init_statement> ::= <expression_statement>
1214 * | <declaration_statement>
1217 expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;
1220 * <conditionopt> ::= <condition>
1223 * note: <conditionopt> is used only by "for" statement.
1224 * if <condition> is ommitted, parser simulates default behaviour,
1225 * that is simulates "true" expression
1229 .true .emit OP_EXPRESSION .emit OP_PUSH_BOOL .emit 2 .emit '1' .emit '\0' .emit OP_END;
1232 * <for_rest_statement> ::= <conditionopt> ";"
1233 * | <conditionopt> ";" <expression>
1236 conditionopt .and semicolon .and for_rest_statement_1;
1237 for_rest_statement_1
1238 for_rest_statement_2 .or .true .emit OP_PUSH_VOID .emit OP_END;
1239 for_rest_statement_2
1240 expression .and .true .emit OP_END;
1243 * <jump_statement> ::= "continue" ";"
1246 * | "return" <expression> ";"
1247 * | "discard" ";" // Fragment shader only.
1250 jump_statement_1 .or jump_statement_2 .or jump_statement_3 .or jump_statement_4 .or
1251 .if (shader_type == 1) jump_statement_5;
1253 "continue" .and semicolon .emit OP_CONTINUE;
1255 "break" .and semicolon .emit OP_BREAK;
1257 "return" .emit OP_RETURN .and optional_space .and expression .and semicolon .emit OP_END;
1259 "return" .emit OP_RETURN .and semicolon .emit OP_PUSH_VOID .emit OP_END;
1261 "discard" .and semicolon .emit OP_DISCARD;
1264 * <__asm_statement> ::= "__asm" <identifier> <asm_arguments> ";"
1266 * note: this is an extension to the standard language specification.
1267 * normally slang disallows __asm statements
1270 "__asm" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;
1273 * <asm_arguments> ::= <asm_argument>
1274 * | <asm_arguments> "," <asm_argument>
1276 * note: this is an extension to the standard language specification.
1277 * normally slang disallows __asm statements
1280 asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;
1282 comma .and asm_argument .and .true .emit OP_END;
1285 * <asm_argument> ::= <variable_identifier>
1288 * note: this is an extension to the standard language specification.
1289 * normally slang disallows __asm statements
1293 variable_identifier .or
1297 variable_identifier .and dot .and field_selection .emit OP_FIELD;
1301 * <translation_unit> ::= <external_declaration>
1302 * | <translation_unit> <external_declaration>
1305 optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and
1306 .loop external_declaration .and optional_space .and
1307 '\0' .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;
1311 * <external_declaration> ::= <function_definition>
1314 external_declaration
1315 precision_stmt .emit DEFAULT_PRECISION .or
1316 function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or
1317 invariant_stmt .emit INVARIANT_STMT .or
1318 declaration .emit EXTERNAL_DECLARATION;
1322 * <precision_stmt> ::= "precision" <precision> <prectype>
1325 "precision" .and space .and precision .error INVALID_PRECISION .and space .and prectype .error INVALID_PRECISION_TYPE .and semicolon;
1328 * <precision> ::= "lowp"
1333 "lowp" .emit PRECISION_LOW .or
1334 "mediump" .emit PRECISION_MEDIUM .or
1335 "highp" .emit PRECISION_HIGH;
1338 * <prectype> ::= "int"
1340 * | "a sampler type"
1343 "int" .emit TYPE_SPECIFIER_INT .or
1344 "float" .emit TYPE_SPECIFIER_FLOAT .or
1345 "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
1346 "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
1347 "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
1348 "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
1349 "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
1350 "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
1351 "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
1352 "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW;
1356 * <invariant_stmt> ::= "invariant" identifier;
1359 "invariant" .and space .and identifier .and semicolon;
1363 * <function_definition> :: <function_prototype> <compound_statement_no_new_scope>
1366 function_prototype .and compound_statement_no_new_scope;
1371 * helper rules, not part of the official language syntax
1381 '0'-'9' .or 'A'-'F' .or 'a'-'f';
1384 'a'-'z' .or 'A'-'Z' .or '_';
1387 id_character_first .or digit_dec;
1390 id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\0';
1393 float_1 .or float_2 .or float_3;
1395 float_fractional_constant .and float_optional_exponent_part .and optional_f_suffix;
1397 float_digit_sequence .and .true .emit '\0' .and float_exponent_part .and optional_f_suffix;
1399 float_digit_sequence .and .true .emit '\0' .and 'f' .emit '\0';
1401 float_fractional_constant
1402 float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;
1403 float_fractional_constant_1
1404 float_digit_sequence .and '.' .and float_digit_sequence;
1405 float_fractional_constant_2
1406 float_digit_sequence .and '.' .and .true .emit '\0';
1407 float_fractional_constant_3
1408 '.' .emit '\0' .and float_digit_sequence;
1410 float_optional_exponent_part
1411 float_exponent_part .or .true .emit '\0';
1413 float_digit_sequence
1414 digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
1417 float_exponent_part_1 .or float_exponent_part_2;
1418 float_exponent_part_1
1419 'e' .and float_optional_sign .and float_digit_sequence;
1420 float_exponent_part_2
1421 'E' .and float_optional_sign .and float_digit_sequence;
1424 float_sign .or .true;
1427 '+' .or '-' .emit '-';
1434 integer_hex .or integer_oct .or integer_dec;
1437 '0' .and integer_hex_1 .emit 0x10 .and digit_hex .emit * .and .loop digit_hex .emit * .and
1443 '0' .emit 8 .emit * .and .loop digit_oct .emit * .and .true .emit '\0';
1446 digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
1449 "true" .emit 2 .emit '1' .emit '\0' .or
1450 "false" .emit 2 .emit '0' .emit '\0';
1459 float .emit OP_PUSH_FLOAT;
1462 integer .emit OP_PUSH_INT;
1465 boolean .emit OP_PUSH_BOOL;
1471 single_space .and .loop single_space;
1474 white_char .or c_style_comment_block .or cpp_style_comment_block;
1477 ' ' .or '\t' .or new_line .or '\v' .or '\f';
1480 cr_lf .or lf_cr .or '\n' .or '\r';
1488 c_style_comment_block
1489 '/' .and '*' .and c_style_comment_rest;
1491 c_style_comment_rest
1492 .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
1493 c_style_comment_rest_1
1494 c_style_comment_end .or c_style_comment_rest_2;
1495 c_style_comment_rest_2
1496 '*' .and c_style_comment_rest;
1498 c_style_comment_char_no_star
1499 '\x2B'-'\xFF' .or '\x01'-'\x29';
1504 cpp_style_comment_block
1505 '/' .and '/' .and cpp_style_comment_block_1;
1506 cpp_style_comment_block_1
1507 cpp_style_comment_block_2 .or cpp_style_comment_block_3;
1508 cpp_style_comment_block_2
1509 .loop cpp_style_comment_char .and new_line;
1510 cpp_style_comment_block_3
1511 .loop cpp_style_comment_char;
1513 cpp_style_comment_char
1514 '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
1519 optional_space .and '&' .and optional_space;*/
1522 optional_space .and '&' .and '&' .and optional_space;
1525 optional_space .and '&' .and '=' .and optional_space;*/
1528 optional_space .and '|' .and optional_space;*/
1531 optional_space .and '|' .and '|' .and optional_space;
1534 optional_space .and '|' .and '=' .and optional_space;*/
1537 optional_space .and '!' .and optional_space;
1540 optional_space .and '!' .and '=' .and optional_space;
1543 optional_space .and '^' .and optional_space;*/
1546 optional_space .and '^' .and '^' .and optional_space;
1549 optional_space .and '^' .and '=' .and optional_space;*/
1552 optional_space .and ':' .and optional_space;
1555 optional_space .and ',' .and optional_space;
1558 optional_space .and '.' .and optional_space;
1561 optional_space .and '=' .and optional_space;
1564 optional_space .and '=' .and '=' .and optional_space;
1567 optional_space .and '>' .and optional_space;
1570 optional_space .and '>' .and '=' .and optional_space;
1573 optional_space .and '>' .and '>' .and optional_space;*/
1575 /*greatergreaterequals
1576 optional_space .and '>' .and '>' .and '=' .and optional_space;*/
1579 optional_space .and '{' .and optional_space;
1582 optional_space .and '[' .and optional_space;
1585 optional_space .and '<' .and optional_space;
1588 optional_space .and '<' .and '=' .and optional_space;
1591 optional_space .and '<' .and '<' .and optional_space;*/
1594 optional_space .and '<' .and '<' .and '=' .and optional_space;*/
1597 optional_space .and '(' .and optional_space;
1600 optional_space .and '-' .and optional_space;
1603 optional_space .and '-' .and '=' .and optional_space;
1606 optional_space .and '-' .and '-' .and optional_space;
1609 optional_space .and '%' .and optional_space;*/
1612 optional_space .and '%' .and '=' .and optional_space;*/
1615 optional_space .and '+' .and optional_space;
1618 optional_space .and '+' .and '=' .and optional_space;
1621 optional_space .and '+' .and '+' .and optional_space;
1624 optional_space .and '?' .and optional_space;
1627 optional_space .and '}' .and optional_space;
1630 optional_space .and ']' .and optional_space;
1633 optional_space .and ')' .and optional_space;
1636 optional_space .and ';' .and optional_space;
1639 optional_space .and '/' .and optional_space;
1642 optional_space .and '/' .and '=' .and optional_space;
1645 optional_space .and '*' .and optional_space;
1648 optional_space .and '*' .and '=' .and optional_space;
1651 optional_space .and '~' .and optional_space;*/
1653 /* string rules - these are used internally by the parser when parsing quoted strings */
1655 .string string_lexer;
1658 lex_first_identifier_character .and .loop lex_next_identifier_character;
1660 lex_first_identifier_character
1661 'a'-'z' .or 'A'-'Z' .or '_';
1663 lex_next_identifier_character
1664 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
1666 /* error rules - these are used by error messages */
1669 '~' .or '`' .or '!' .or '@' .or '#' .or '$' .or '%' .or '^' .or '&' .or '*' .or '(' .or ')' .or
1670 '-' .or '+' .or '=' .or '|' .or '\\' .or '[' .or ']' .or '{' .or '}' .or ':' .or ';' .or '"' .or
1671 '\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;
1674 id_character_first .and .loop id_character_next;