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> "["
841 * <constant_expression> "]"
842 * | <init_declarator_list> "," <identifier> "="
846 single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and
847 .true .emit DECLARATOR_NONE;
848 init_declarator_list_1
849 comma .and identifier .emit VARIABLE_IDENTIFIER .and init_declarator_list_2;
850 init_declarator_list_2
851 init_declarator_list_3 .or init_declarator_list_4 .or .true .emit VARIABLE_NONE;
852 init_declarator_list_3
853 equals .and initializer .emit VARIABLE_INITIALIZER;
854 init_declarator_list_4
855 lbracket .and init_declarator_list_5 .and rbracket;
856 init_declarator_list_5
857 constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
860 * <single_declaration> ::= <fully_specified_type>
861 * | <fully_specified_type> <identifier>
862 * | <fully_specified_type> <identifier> "[" "]"
863 * | <fully_specified_type> <identifier> "["
864 * <constant_expression> "]"
865 * | <fully_specified_type> <identifier> "=" <initializer>
868 single_declaration_nospace .or single_declaration_space;
869 single_declaration_space
870 fully_specified_type_space .and single_declaration_space_1;
871 single_declaration_nospace
872 fully_specified_type_nospace .and single_declaration_nospace_1;
873 single_declaration_space_1
874 single_declaration_space_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
875 single_declaration_nospace_1
876 single_declaration_nospace_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
877 single_declaration_space_2
878 space .and identifier .and single_declaration_3;
879 single_declaration_nospace_2
880 identifier .and single_declaration_3;
882 single_declaration_4 .or single_declaration_5 .or .true .emit VARIABLE_NONE;
884 equals .and initializer .emit VARIABLE_INITIALIZER;
886 lbracket .and single_declaration_6 .and rbracket;
888 constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
891 * <fully_specified_type> ::= <opt_invariant> <opt_centroid> <opt_qualifer> <opt_precision> <type_specifier>
893 * Example: "invariant varying highp vec3"
895 fully_specified_type_space
896 fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;
897 fully_specified_type_nospace
898 fully_specified_type_optinvariant .and fully_specified_type_optcentroid .and fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;
899 fully_specified_type_optinvariant
900 fully_specified_type_invariant .or .true .emit TYPE_VARIANT;
901 fully_specified_type_invariant
902 invariant_qualifier .and space;
903 fully_specified_type_optcentroid
904 fully_specified_type_centroid .or .true .emit TYPE_CENTER;
905 fully_specified_type_centroid
906 centroid_qualifier .and space;
907 fully_specified_type_optqual
908 fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;
909 fully_specified_type_qual
910 type_qualifier .and space;
911 fully_specified_type_optprec
912 fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;
913 fully_specified_type_prec
914 precision .and space;
917 * <invariant_qualifier> ::= "invariant"
920 "invariant" .emit TYPE_INVARIANT;
923 "centroid" .emit TYPE_CENTROID;
927 * <type_qualifier> ::= "const"
928 * | "attribute" // Vertex only.
934 * note: this is an extension to the standard language specification,
935 * normally slang disallows __fixed_output and __fixed_input type qualifiers
938 "const" .emit TYPE_QUALIFIER_CONST .or
939 .if (shader_type == 2) "attribute" .emit TYPE_QUALIFIER_ATTRIBUTE .or
940 "varying" .emit TYPE_QUALIFIER_VARYING .or
941 "uniform" .emit TYPE_QUALIFIER_UNIFORM .or
942 .if (parsing_builtin != 0) "__fixed_output" .emit TYPE_QUALIFIER_FIXEDOUTPUT .or
943 .if (parsing_builtin != 0) "__fixed_input" .emit TYPE_QUALIFIER_FIXEDINPUT;
946 * <type_specifier> ::= "void"
972 * | "sampler1DShadow"
973 * | "sampler2DShadow"
975 * | "sampler2DRectShadow"
976 * | <struct_specifier>
980 "void" .emit TYPE_SPECIFIER_VOID .or
981 "float" .emit TYPE_SPECIFIER_FLOAT .or
982 "int" .emit TYPE_SPECIFIER_INT .or
983 "bool" .emit TYPE_SPECIFIER_BOOL .or
984 "vec2" .emit TYPE_SPECIFIER_VEC2 .or
985 "vec3" .emit TYPE_SPECIFIER_VEC3 .or
986 "vec4" .emit TYPE_SPECIFIER_VEC4 .or
987 "bvec2" .emit TYPE_SPECIFIER_BVEC2 .or
988 "bvec3" .emit TYPE_SPECIFIER_BVEC3 .or
989 "bvec4" .emit TYPE_SPECIFIER_BVEC4 .or
990 "ivec2" .emit TYPE_SPECIFIER_IVEC2 .or
991 "ivec3" .emit TYPE_SPECIFIER_IVEC3 .or
992 "ivec4" .emit TYPE_SPECIFIER_IVEC4 .or
993 "mat2" .emit TYPE_SPECIFIER_MAT2 .or
994 "mat3" .emit TYPE_SPECIFIER_MAT3 .or
995 "mat4" .emit TYPE_SPECIFIER_MAT4 .or
996 "mat2x3" .emit TYPE_SPECIFIER_MAT23 .or
997 "mat3x2" .emit TYPE_SPECIFIER_MAT32 .or
998 "mat2x4" .emit TYPE_SPECIFIER_MAT24 .or
999 "mat4x2" .emit TYPE_SPECIFIER_MAT42 .or
1000 "mat3x4" .emit TYPE_SPECIFIER_MAT34 .or
1001 "mat4x3" .emit TYPE_SPECIFIER_MAT43 .or
1002 "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
1003 "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
1004 "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
1005 "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
1006 "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
1007 "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
1008 "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
1009 "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or
1010 type_name .emit TYPE_SPECIFIER_TYPENAME;
1011 type_specifier_nospace
1012 struct_specifier .emit TYPE_SPECIFIER_STRUCT;
1015 * <struct_specifier> ::= "struct" <identifier> "{" <struct_declaration_list> "}"
1016 * | "struct" "{" <struct_declaration_list> "}"
1019 "struct" .and struct_specifier_1 .and optional_space .and lbrace .error LBRACE_EXPECTED .and
1020 struct_declaration_list .and rbrace .emit FIELD_NONE;
1022 struct_specifier_2 .or .true .emit '\0';
1024 space .and identifier;
1027 * <struct_declaration_list> ::= <struct_declaration>
1028 * | <struct_declaration_list> <struct_declaration>
1030 struct_declaration_list
1031 struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;
1034 * <struct_declaration> ::= <type_specifier> <struct_declarator_list> ";"
1037 struct_declaration_nospace .or struct_declaration_space;
1038 struct_declaration_space
1039 type_specifier_space .and space .and struct_declarator_list .and semicolon .emit FIELD_NONE;
1040 struct_declaration_nospace
1041 type_specifier_nospace .and struct_declarator_list .and semicolon .emit FIELD_NONE;
1044 * <struct_declarator_list> ::= <struct_declarator>
1045 * | <struct_declarator_list> "," <struct_declarator>
1047 struct_declarator_list
1048 struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT;
1049 struct_declarator_list_1
1050 comma .and struct_declarator;
1053 * <struct_declarator> ::= <identifier>
1054 * | <identifier> "[" <constant_expression> "]"
1057 identifier .and struct_declarator_1;
1059 struct_declarator_2 .emit FIELD_ARRAY .or .true .emit FIELD_NONE;
1061 lbracket .and constant_expression .and rbracket;
1064 * <initializer> ::= <assignment_expression>
1067 assignment_expression .and .true .emit OP_END;
1070 * <declaration_statement> ::= <declaration>
1072 declaration_statement
1076 * <statement> ::= <compound_statement>
1077 * | <simple_statement>
1080 compound_statement .or simple_statement;
1082 compound_statement .or statement_space_1;
1084 space .and simple_statement;
1087 * <simple_statement> ::= <__asm_statement>
1088 * | <selection_statement>
1089 * | <iteration_statement>
1090 * | <jump_statement>
1091 * | <expression_statement>
1092 * | <declaration_statement>
1094 * note: this is an extension to the standard language specification.
1095 * normally slang disallows use of __asm statements
1098 .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or
1099 selection_statement .or
1100 iteration_statement .or
1101 precision_stmt .emit OP_PRECISION .or
1103 expression_statement .emit OP_EXPRESSION .or
1104 declaration_statement .emit OP_DECLARE;
1107 * <compound_statement> ::= "{" "}"
1108 * | "{" <statement_list> "}"
1111 compound_statement_1 .emit OP_BLOCK_BEGIN_NEW_SCOPE .and .true .emit OP_END;
1112 compound_statement_1
1113 compound_statement_2 .or compound_statement_3;
1114 compound_statement_2
1116 compound_statement_3
1117 lbrace .and statement_list .and rbrace;
1120 * <statement_no_new_scope> ::= <compound_statement_no_new_scope>
1121 * | <simple_statement>
1123 statement_no_new_scope
1124 compound_statement_no_new_scope .or simple_statement;
1127 * <compound_statement_no_new_scope> ::= "{" "}"
1128 * | "{" <statement_list> "}"
1130 compound_statement_no_new_scope
1131 compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;
1132 compound_statement_no_new_scope_1
1133 compound_statement_no_new_scope_2 .or compound_statement_no_new_scope_3;
1134 compound_statement_no_new_scope_2
1136 compound_statement_no_new_scope_3
1137 lbrace .and statement_list .and rbrace;
1140 * <statement_list> ::= <statement>
1141 * | <statement_list> <statement>
1144 statement .and .loop statement;
1147 * <expression_statement> ::= ";"
1148 * | <expression> ";"
1150 expression_statement
1151 expression_statement_1 .or expression_statement_2;
1152 expression_statement_1
1153 semicolon .emit OP_PUSH_VOID .emit OP_END;
1154 expression_statement_2
1155 expression .and semicolon .emit OP_END;
1158 * <selection_statement> ::= "if" "(" <expression> ")" <selection_rest_statement>
1161 "if" .emit OP_IF .and lparen .error LPAREN_EXPECTED .and expression .and
1162 rparen .error RPAREN_EXPECTED .emit OP_END .and selection_rest_statement;
1165 * <selection_rest_statement> ::= <statement> "else" <statement>
1168 selection_rest_statement
1169 statement .and selection_rest_statement_1;
1170 selection_rest_statement_1
1171 selection_rest_statement_2 .or .true .emit OP_EXPRESSION .emit OP_PUSH_VOID .emit OP_END;
1172 selection_rest_statement_2
1173 "else" .and optional_space .and statement;
1176 * <condition> ::= <expression>
1177 * | <fully_specified_type> <identifier> "=" <initializer>
1179 * note: if <condition_1> is executed, the emit format must
1180 * match <declaration> emit format
1183 condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or
1184 condition_3 .emit OP_EXPRESSION;
1186 condition_1_nospace .or condition_1_space;
1188 fully_specified_type_nospace .and condition_2;
1190 fully_specified_type_space .and space .and condition_2;
1192 identifier .emit VARIABLE_IDENTIFIER .and equals .emit VARIABLE_INITIALIZER .and
1193 initializer .and .true .emit DECLARATOR_NONE;
1195 expression .and .true .emit OP_END;
1198 * <iteration_statement> ::= "while" "(" <condition> ")" <statement>
1199 * | "do" <statement> "while" "(" <expression> ")" ";"
1200 * | "for" "(" <for_init_statement> <for_rest_statement> ")"
1201 * <statement_no_new_scope>
1204 iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;
1205 iteration_statement_1
1206 "while" .emit OP_WHILE .and lparen .error LPAREN_EXPECTED .and condition .and
1207 rparen .error RPAREN_EXPECTED .and statement;
1208 iteration_statement_2
1209 "do" .emit OP_DO .and statement_space .and "while" .and lparen .error LPAREN_EXPECTED .and
1210 expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;
1211 iteration_statement_3
1212 "for" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and
1213 for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement_no_new_scope;
1216 * <for_init_statement> ::= <expression_statement>
1217 * | <declaration_statement>
1220 expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;
1223 * <conditionopt> ::= <condition>
1226 * note: <conditionopt> is used only by "for" statement.
1227 * if <condition> is ommitted, parser simulates default behaviour,
1228 * that is simulates "true" expression
1232 .true .emit OP_EXPRESSION .emit OP_PUSH_BOOL .emit 2 .emit '1' .emit '\0' .emit OP_END;
1235 * <for_rest_statement> ::= <conditionopt> ";"
1236 * | <conditionopt> ";" <expression>
1239 conditionopt .and semicolon .and for_rest_statement_1;
1240 for_rest_statement_1
1241 for_rest_statement_2 .or .true .emit OP_PUSH_VOID .emit OP_END;
1242 for_rest_statement_2
1243 expression .and .true .emit OP_END;
1246 * <jump_statement> ::= "continue" ";"
1249 * | "return" <expression> ";"
1250 * | "discard" ";" // Fragment shader only.
1253 jump_statement_1 .or jump_statement_2 .or jump_statement_3 .or jump_statement_4 .or
1254 .if (shader_type == 1) jump_statement_5;
1256 "continue" .and semicolon .emit OP_CONTINUE;
1258 "break" .and semicolon .emit OP_BREAK;
1260 "return" .emit OP_RETURN .and optional_space .and expression .and semicolon .emit OP_END;
1262 "return" .emit OP_RETURN .and semicolon .emit OP_PUSH_VOID .emit OP_END;
1264 "discard" .and semicolon .emit OP_DISCARD;
1267 * <__asm_statement> ::= "__asm" <identifier> <asm_arguments> ";"
1269 * note: this is an extension to the standard language specification.
1270 * normally slang disallows __asm statements
1273 "__asm" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;
1276 * <asm_arguments> ::= <asm_argument>
1277 * | <asm_arguments> "," <asm_argument>
1279 * note: this is an extension to the standard language specification.
1280 * normally slang disallows __asm statements
1283 asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;
1285 comma .and asm_argument .and .true .emit OP_END;
1288 * <asm_argument> ::= <variable_identifier>
1291 * note: this is an extension to the standard language specification.
1292 * normally slang disallows __asm statements
1296 variable_identifier .or
1300 variable_identifier .and dot .and field_selection .emit OP_FIELD;
1304 * <translation_unit> ::= <external_declaration>
1305 * | <translation_unit> <external_declaration>
1308 optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and
1309 .loop external_declaration .and optional_space .and
1310 '\0' .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;
1314 * <external_declaration> ::= <function_definition>
1317 external_declaration
1318 precision_stmt .emit DEFAULT_PRECISION .or
1319 function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or
1320 invariant_stmt .emit INVARIANT_STMT .or
1321 declaration .emit EXTERNAL_DECLARATION;
1325 * <precision_stmt> ::= "precision" <precision> <prectype>
1328 "precision" .and space .and precision .error INVALID_PRECISION .and space .and prectype .error INVALID_PRECISION_TYPE .and semicolon;
1331 * <precision> ::= "lowp"
1336 "lowp" .emit PRECISION_LOW .or
1337 "mediump" .emit PRECISION_MEDIUM .or
1338 "highp" .emit PRECISION_HIGH;
1341 * <prectype> ::= "int"
1343 * | "a sampler type"
1346 "int" .emit TYPE_SPECIFIER_INT .or
1347 "float" .emit TYPE_SPECIFIER_FLOAT .or
1348 "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
1349 "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
1350 "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
1351 "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
1352 "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
1353 "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
1354 "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
1355 "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW;
1359 * <invariant_stmt> ::= "invariant" identifier;
1362 "invariant" .and space .and identifier .and semicolon;
1366 * <function_definition> :: <function_prototype> <compound_statement_no_new_scope>
1369 function_prototype .and compound_statement_no_new_scope;
1374 * helper rules, not part of the official language syntax
1384 '0'-'9' .or 'A'-'F' .or 'a'-'f';
1387 'a'-'z' .or 'A'-'Z' .or '_';
1390 id_character_first .or digit_dec;
1393 id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\0';
1396 float_1 .or float_2 .or float_3;
1398 float_fractional_constant .and float_optional_exponent_part .and optional_f_suffix;
1400 float_digit_sequence .and .true .emit '\0' .and float_exponent_part .and optional_f_suffix;
1402 float_digit_sequence .and .true .emit '\0' .and 'f' .emit '\0';
1404 float_fractional_constant
1405 float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;
1406 float_fractional_constant_1
1407 float_digit_sequence .and '.' .and float_digit_sequence;
1408 float_fractional_constant_2
1409 float_digit_sequence .and '.' .and .true .emit '\0';
1410 float_fractional_constant_3
1411 '.' .emit '\0' .and float_digit_sequence;
1413 float_optional_exponent_part
1414 float_exponent_part .or .true .emit '\0';
1416 float_digit_sequence
1417 digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
1420 float_exponent_part_1 .or float_exponent_part_2;
1421 float_exponent_part_1
1422 'e' .and float_optional_sign .and float_digit_sequence;
1423 float_exponent_part_2
1424 'E' .and float_optional_sign .and float_digit_sequence;
1427 float_sign .or .true;
1430 '+' .or '-' .emit '-';
1437 integer_hex .or integer_oct .or integer_dec;
1440 '0' .and integer_hex_1 .emit 0x10 .and digit_hex .emit * .and .loop digit_hex .emit * .and
1446 '0' .emit 8 .emit * .and .loop digit_oct .emit * .and .true .emit '\0';
1449 digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
1452 "true" .emit 2 .emit '1' .emit '\0' .or
1453 "false" .emit 2 .emit '0' .emit '\0';
1462 float .emit OP_PUSH_FLOAT;
1465 integer .emit OP_PUSH_INT;
1468 boolean .emit OP_PUSH_BOOL;
1474 single_space .and .loop single_space;
1477 white_char .or c_style_comment_block .or cpp_style_comment_block;
1480 ' ' .or '\t' .or new_line .or '\v' .or '\f';
1483 cr_lf .or lf_cr .or '\n' .or '\r';
1491 c_style_comment_block
1492 '/' .and '*' .and c_style_comment_rest;
1494 c_style_comment_rest
1495 .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
1496 c_style_comment_rest_1
1497 c_style_comment_end .or c_style_comment_rest_2;
1498 c_style_comment_rest_2
1499 '*' .and c_style_comment_rest;
1501 c_style_comment_char_no_star
1502 '\x2B'-'\xFF' .or '\x01'-'\x29';
1507 cpp_style_comment_block
1508 '/' .and '/' .and cpp_style_comment_block_1;
1509 cpp_style_comment_block_1
1510 cpp_style_comment_block_2 .or cpp_style_comment_block_3;
1511 cpp_style_comment_block_2
1512 .loop cpp_style_comment_char .and new_line;
1513 cpp_style_comment_block_3
1514 .loop cpp_style_comment_char;
1516 cpp_style_comment_char
1517 '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
1522 optional_space .and '&' .and optional_space;*/
1525 optional_space .and '&' .and '&' .and optional_space;
1528 optional_space .and '&' .and '=' .and optional_space;*/
1531 optional_space .and '|' .and optional_space;*/
1534 optional_space .and '|' .and '|' .and optional_space;
1537 optional_space .and '|' .and '=' .and optional_space;*/
1540 optional_space .and '!' .and optional_space;
1543 optional_space .and '!' .and '=' .and optional_space;
1546 optional_space .and '^' .and optional_space;*/
1549 optional_space .and '^' .and '^' .and optional_space;
1552 optional_space .and '^' .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 optional_space;
1567 optional_space .and '=' .and '=' .and optional_space;
1570 optional_space .and '>' .and optional_space;
1573 optional_space .and '>' .and '=' .and optional_space;
1576 optional_space .and '>' .and '>' .and optional_space;*/
1578 /*greatergreaterequals
1579 optional_space .and '>' .and '>' .and '=' .and optional_space;*/
1582 optional_space .and '{' .and optional_space;
1585 optional_space .and '[' .and optional_space;
1588 optional_space .and '<' .and optional_space;
1591 optional_space .and '<' .and '=' .and optional_space;
1594 optional_space .and '<' .and '<' .and optional_space;*/
1597 optional_space .and '<' .and '<' .and '=' .and optional_space;*/
1600 optional_space .and '(' .and optional_space;
1603 optional_space .and '-' .and optional_space;
1606 optional_space .and '-' .and '=' .and optional_space;
1609 optional_space .and '-' .and '-' .and optional_space;
1612 optional_space .and '%' .and optional_space;*/
1615 optional_space .and '%' .and '=' .and optional_space;*/
1618 optional_space .and '+' .and optional_space;
1621 optional_space .and '+' .and '=' .and optional_space;
1624 optional_space .and '+' .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 optional_space;
1645 optional_space .and '/' .and '=' .and optional_space;
1648 optional_space .and '*' .and optional_space;
1651 optional_space .and '*' .and '=' .and optional_space;
1654 optional_space .and '~' .and optional_space;*/
1656 /* string rules - these are used internally by the parser when parsing quoted strings */
1658 .string string_lexer;
1661 lex_first_identifier_character .and .loop lex_next_identifier_character;
1663 lex_first_identifier_character
1664 'a'-'z' .or 'A'-'Z' .or '_';
1666 lex_next_identifier_character
1667 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
1669 /* error rules - these are used by error messages */
1672 '~' .or '`' .or '!' .or '@' .or '#' .or '$' .or '%' .or '^' .or '&' .or '*' .or '(' .or ')' .or
1673 '-' .or '+' .or '=' .or '|' .or '\\' .or '[' .or ']' .or '{' .or '}' .or ':' .or ';' .or '"' .or
1674 '\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;
1677 id_character_first .and .loop id_character_next;