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 consideration:
36 * - when adding new operators that were marked as reserved in the initial specification,
37 * one must only uncomment particular lines of code that refer to operators being added;
38 * - when adding new shader target, one must reserve new value for shader_type register and
39 * use it in .if constructs for symbols that are exclusive for that shader;
40 * - some symbols mimic output of other symbols - the best example is the "for" construct:
41 * expression "for (foo(); ; bar())" is seen as "for (foo(); true; bar())" by the output
42 * processor - hence, special care must be taken when rearranging output of essential symbols;
43 * - order of single-quoted tokens does matter in alternatives - so do not parse "<" operator
44 * before "<<" and "<<" before "<<=";
45 * - all double-quoted tokens are internally preprocessed to eliminate problems with parsing
46 * strings that are prefixes of other strings, like "sampler1D" and "sampler1DShadow";
49 .syntax translation_unit;
51 /* revision number - increment after each change affecting emitted output */
54 /* external declaration (or precision or invariant stmt) */
55 .emtcode EXTERNAL_NULL 0
56 .emtcode EXTERNAL_FUNCTION_DEFINITION 1
57 .emtcode EXTERNAL_DECLARATION 2
58 .emtcode DEFAULT_PRECISION 3
59 .emtcode INVARIANT_STMT 4
62 .emtcode PRECISION_DEFAULT 0
63 .emtcode PRECISION_LOW 1
64 .emtcode PRECISION_MEDIUM 2
65 .emtcode PRECISION_HIGH 3
68 .emtcode DECLARATION_FUNCTION_PROTOTYPE 1
69 .emtcode DECLARATION_INIT_DECLARATOR_LIST 2
72 .emtcode FUNCTION_ORDINARY 0
73 .emtcode FUNCTION_CONSTRUCTOR 1
74 .emtcode FUNCTION_OPERATOR 2
77 .emtcode OPERATOR_ADDASSIGN 1
78 .emtcode OPERATOR_SUBASSIGN 2
79 .emtcode OPERATOR_MULASSIGN 3
80 .emtcode OPERATOR_DIVASSIGN 4
81 /*.emtcode OPERATOR_MODASSIGN 5*/
82 /*.emtcode OPERATOR_LSHASSIGN 6*/
83 /*.emtcode OPERATOR_RSHASSIGN 7*/
84 /*.emtcode OPERATOR_ORASSIGN 8*/
85 /*.emtcode OPERATOR_XORASSIGN 9*/
86 /*.emtcode OPERATOR_ANDASSIGN 10*/
87 .emtcode OPERATOR_LOGICALXOR 11
88 /*.emtcode OPERATOR_BITOR 12*/
89 /*.emtcode OPERATOR_BITXOR 13*/
90 /*.emtcode OPERATOR_BITAND 14*/
91 .emtcode OPERATOR_LESS 15
92 .emtcode OPERATOR_GREATER 16
93 .emtcode OPERATOR_LESSEQUAL 17
94 .emtcode OPERATOR_GREATEREQUAL 18
95 /*.emtcode OPERATOR_LSHIFT 19*/
96 /*.emtcode OPERATOR_RSHIFT 20*/
97 .emtcode OPERATOR_MULTIPLY 21
98 .emtcode OPERATOR_DIVIDE 22
99 /*.emtcode OPERATOR_MODULUS 23*/
100 .emtcode OPERATOR_INCREMENT 24
101 .emtcode OPERATOR_DECREMENT 25
102 .emtcode OPERATOR_PLUS 26
103 .emtcode OPERATOR_MINUS 27
104 /*.emtcode OPERATOR_COMPLEMENT 28*/
105 .emtcode OPERATOR_NOT 29
107 /* init declarator list */
108 .emtcode DECLARATOR_NONE 0
109 .emtcode DECLARATOR_NEXT 1
111 /* variable declaration */
112 .emtcode VARIABLE_NONE 0
113 .emtcode VARIABLE_IDENTIFIER 1
114 .emtcode VARIABLE_INITIALIZER 2
115 .emtcode VARIABLE_ARRAY_EXPLICIT 3
116 .emtcode VARIABLE_ARRAY_UNKNOWN 4
119 .emtcode TYPE_QUALIFIER_NONE 0
120 .emtcode TYPE_QUALIFIER_CONST 1
121 .emtcode TYPE_QUALIFIER_ATTRIBUTE 2
122 .emtcode TYPE_QUALIFIER_VARYING 3
123 .emtcode TYPE_QUALIFIER_UNIFORM 4
124 .emtcode TYPE_QUALIFIER_FIXEDOUTPUT 5
125 .emtcode TYPE_QUALIFIER_FIXEDINPUT 6
128 .emtcode TYPE_SPECIFIER_VOID 0
129 .emtcode TYPE_SPECIFIER_BOOL 1
130 .emtcode TYPE_SPECIFIER_BVEC2 2
131 .emtcode TYPE_SPECIFIER_BVEC3 3
132 .emtcode TYPE_SPECIFIER_BVEC4 4
133 .emtcode TYPE_SPECIFIER_INT 5
134 .emtcode TYPE_SPECIFIER_IVEC2 6
135 .emtcode TYPE_SPECIFIER_IVEC3 7
136 .emtcode TYPE_SPECIFIER_IVEC4 8
137 .emtcode TYPE_SPECIFIER_FLOAT 9
138 .emtcode TYPE_SPECIFIER_VEC2 10
139 .emtcode TYPE_SPECIFIER_VEC3 11
140 .emtcode TYPE_SPECIFIER_VEC4 12
141 .emtcode TYPE_SPECIFIER_MAT2 13
142 .emtcode TYPE_SPECIFIER_MAT3 14
143 .emtcode TYPE_SPECIFIER_MAT4 15
144 .emtcode TYPE_SPECIFIER_SAMPLER1D 16
145 .emtcode TYPE_SPECIFIER_SAMPLER2D 17
146 .emtcode TYPE_SPECIFIER_SAMPLER3D 18
147 .emtcode TYPE_SPECIFIER_SAMPLERCUBE 19
148 .emtcode TYPE_SPECIFIER_SAMPLER1DSHADOW 20
149 .emtcode TYPE_SPECIFIER_SAMPLER2DSHADOW 21
150 .emtcode TYPE_SPECIFIER_SAMPLER2DRECT 22
151 .emtcode TYPE_SPECIFIER_SAMPLER2DRECTSHADOW 23
152 .emtcode TYPE_SPECIFIER_STRUCT 24
153 .emtcode TYPE_SPECIFIER_TYPENAME 25
156 .emtcode TYPE_SPECIFIER_MAT23 26
157 .emtcode TYPE_SPECIFIER_MAT32 27
158 .emtcode TYPE_SPECIFIER_MAT24 28
159 .emtcode TYPE_SPECIFIER_MAT42 29
160 .emtcode TYPE_SPECIFIER_MAT34 30
161 .emtcode TYPE_SPECIFIER_MAT43 31
164 /* structure field */
165 .emtcode FIELD_NONE 0
166 .emtcode FIELD_NEXT 1
167 .emtcode FIELD_ARRAY 2
171 .emtcode OP_BLOCK_BEGIN_NO_NEW_SCOPE 1
172 .emtcode OP_BLOCK_BEGIN_NEW_SCOPE 2
173 .emtcode OP_DECLARE 3
176 .emtcode OP_CONTINUE 6
177 .emtcode OP_DISCARD 7
179 .emtcode OP_EXPRESSION 9
184 .emtcode OP_PUSH_VOID 14
185 .emtcode OP_PUSH_BOOL 15
186 .emtcode OP_PUSH_INT 16
187 .emtcode OP_PUSH_FLOAT 17
188 .emtcode OP_PUSH_IDENTIFIER 18
189 .emtcode OP_SEQUENCE 19
190 .emtcode OP_ASSIGN 20
191 .emtcode OP_ADDASSIGN 21
192 .emtcode OP_SUBASSIGN 22
193 .emtcode OP_MULASSIGN 23
194 .emtcode OP_DIVASSIGN 24
195 /*.emtcode OP_MODASSIGN 25*/
196 /*.emtcode OP_LSHASSIGN 26*/
197 /*.emtcode OP_RSHASSIGN 27*/
198 /*.emtcode OP_ORASSIGN 28*/
199 /*.emtcode OP_XORASSIGN 29*/
200 /*.emtcode OP_ANDASSIGN 30*/
201 .emtcode OP_SELECT 31
202 .emtcode OP_LOGICALOR 32
203 .emtcode OP_LOGICALXOR 33
204 .emtcode OP_LOGICALAND 34
205 /*.emtcode OP_BITOR 35*/
206 /*.emtcode OP_BITXOR 36*/
207 /*.emtcode OP_BITAND 37*/
209 .emtcode OP_NOTEQUAL 39
211 .emtcode OP_GREATER 41
212 .emtcode OP_LESSEQUAL 42
213 .emtcode OP_GREATEREQUAL 43
214 /*.emtcode OP_LSHIFT 44*/
215 /*.emtcode OP_RSHIFT 45*/
217 .emtcode OP_SUBTRACT 47
218 .emtcode OP_MULTIPLY 48
219 .emtcode OP_DIVIDE 49
220 /*.emtcode OP_MODULUS 50*/
221 .emtcode OP_PREINCREMENT 51
222 .emtcode OP_PREDECREMENT 52
225 /*.emtcode OP_COMPLEMENT 55*/
227 .emtcode OP_SUBSCRIPT 57
230 .emtcode OP_POSTINCREMENT 60
231 .emtcode OP_POSTDECREMENT 61
232 .emtcode OP_PRECISION 62
234 /* parameter qualifier */
235 .emtcode PARAM_QUALIFIER_IN 0
236 .emtcode PARAM_QUALIFIER_OUT 1
237 .emtcode PARAM_QUALIFIER_INOUT 2
239 /* function parameter */
240 .emtcode PARAMETER_NONE 0
241 .emtcode PARAMETER_NEXT 1
243 /* function parameter array presence */
244 .emtcode PARAMETER_ARRAY_NOT_PRESENT 0
245 .emtcode PARAMETER_ARRAY_PRESENT 1
247 /* INVALID_EXTERNAL_DECLARATION seems to be reported when there's */
248 /* any syntax errors... */
249 .errtext INVALID_EXTERNAL_DECLARATION "2001: Syntax error."
250 .errtext INVALID_OPERATOR_OVERRIDE "2002: Invalid operator override."
251 .errtext LBRACE_EXPECTED "2003: '{' expected but '$err_token$' found."
252 .errtext LPAREN_EXPECTED "2004: '(' expected but '$err_token$' found."
253 .errtext RPAREN_EXPECTED "2005: ')' expected but '$err_token$' found."
254 .errtext INVALID_PRECISION "2006: Invalid precision specifier '$err_token$'."
255 .errtext INVALID_PRECISION_TYPE "2007: Invalid precision type '$err_token$'."
258 /* tells whether the shader that is being parsed is a built-in shader or not */
259 /* 0 - normal behaviour */
260 /* 1 - accepts constructor and operator definitions and __asm statements */
261 /* the implementation will set it to 1 when compiling internal built-in shaders */
262 .regbyte parsing_builtin 0
264 /* holds the type of the shader being parsed; possible values are listed below */
265 /* FRAGMENT_SHADER 1 */
266 /* VERTEX_SHADER 2 */
267 /* shader type is set by the caller before parsing */
268 .regbyte shader_type 0
271 <variable_identifier> ::= <identifier>
274 identifier .emit OP_PUSH_IDENTIFIER;
277 <primary_expression> ::= <variable_identifier>
281 | "(" <expression> ")"
284 floatconstant .or boolconstant .or intconstant .or variable_identifier .or primary_expression_1;
286 lparen .and expression .and rparen;
289 <postfix_expression> ::= <primary_expression>
290 | <postfix_expression> "[" <integer_expression> "]"
292 | <postfix_expression> "." <field_selection>
293 | <postfix_expression> "++"
294 | <postfix_expression> "--"
297 postfix_expression_1 .and .loop postfix_expression_2;
299 function_call .or primary_expression;
301 postfix_expression_3 .or postfix_expression_4 .or
302 plusplus .emit OP_POSTINCREMENT .or
303 minusminus .emit OP_POSTDECREMENT;
305 lbracket .and integer_expression .and rbracket .emit OP_SUBSCRIPT;
307 dot .and field_selection .emit OP_FIELD;
310 <integer_expression> ::= <expression>
316 <function_call> ::= <function_call_generic>
319 function_call_generic .emit OP_CALL .and .true .emit OP_END;
322 <function_call_generic> ::= <function_call_header_with_parameters> ")"
323 | <function_call_header_no_parameters> ")"
325 function_call_generic
326 function_call_generic_1 .or function_call_generic_2;
327 function_call_generic_1
328 function_call_header_with_parameters .and rparen .error RPAREN_EXPECTED;
329 function_call_generic_2
330 function_call_header_no_parameters .and rparen .error RPAREN_EXPECTED;
333 <function_call_header_no_parameters>::= <function_call_header> "void"
334 | <function_call_header>
336 function_call_header_no_parameters
337 function_call_header .and function_call_header_no_parameters_1;
338 function_call_header_no_parameters_1
342 <function_call_header_with_parameters>::= <function_call_header> <assignment_expression>
343 | <function_call_header_with_parameters> ","
344 <assignment_expression>
346 function_call_header_with_parameters
347 function_call_header .and assignment_expression .and .true .emit OP_END .and
348 .loop function_call_header_with_parameters_1;
349 function_call_header_with_parameters_1
350 comma .and assignment_expression .and .true .emit OP_END;
353 <function_call_header> ::= <function_identifier> "("
356 function_identifier .and lparen;
359 <function_identifier> ::= <constructor_identifier>
362 note: <constructor_identifier> has been deleted
368 <unary_expression> ::= <postfix_expression>
369 | "++" <unary_expression>
370 | "--" <unary_expression>
371 | <unary_operator> <unary_expression>
373 <unary_operator> ::= "+"
379 postfix_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or
380 unary_expression_4 .or unary_expression_5/* .or unary_expression_6*/;
382 plusplus .and unary_expression .and .true .emit OP_PREINCREMENT;
384 minusminus .and unary_expression .and .true .emit OP_PREDECREMENT;
386 plus .and unary_expression .and .true .emit OP_PLUS;
388 minus .and unary_expression .and .true .emit OP_MINUS;
390 bang .and unary_expression .and .true .emit OP_NOT;
392 tilde .and unary_expression .and .true .emit OP_COMPLEMENT;*/
395 <multiplicative_expression> ::= <unary_expression>
396 | <multiplicative_expression> "*" <unary_expression>
397 | <multiplicative_expression> "/" <unary_expression>
398 | <multiplicative_expression> "%" <unary_expression> // reserved
400 multiplicative_expression
401 unary_expression .and .loop multiplicative_expression_1;
402 multiplicative_expression_1
403 multiplicative_expression_2 .or multiplicative_expression_3/* .or multiplicative_expression_4*/;
404 multiplicative_expression_2
405 star .and unary_expression .and .true .emit OP_MULTIPLY;
406 multiplicative_expression_3
407 slash .and unary_expression .and .true .emit OP_DIVIDE;
408 /*multiplicative_expression_4
409 percent .and unary_expression .and .true .emit OP_MODULUS;*/
412 <additive_expression> ::= <multiplicative_expression>
413 | <additive_expression> "+" <multiplicative_expression>
414 | <additive_expression> "-" <multiplicative_expression>
417 multiplicative_expression .and .loop additive_expression_1;
418 additive_expression_1
419 additive_expression_2 .or additive_expression_3;
420 additive_expression_2
421 plus .and multiplicative_expression .and .true .emit OP_ADD;
422 additive_expression_3
423 minus .and multiplicative_expression .and .true .emit OP_SUBTRACT;
426 <shift_expression> ::= <additive_expression>
427 | <shift_expression> "<<" <additive_expression> // reserved
428 | <shift_expression> ">>" <additive_expression> // reserved
431 additive_expression/* .and .loop shift_expression_1*/;
433 shift_expression_2 .or shift_expression_3;*/
435 lessless .and additive_expression .and .true .emit OP_LSHIFT;*/
437 greatergreater .and additive_expression .and .true .emit OP_RSHIFT;*/
440 <relational_expression> ::= <shift_expression>
441 | <relational_expression> "<" <shift_expression>
442 | <relational_expression> ">" <shift_expression>
443 | <relational_expression> "<=" <shift_expression>
444 | <relational_expression> ">=" <shift_expression>
446 relational_expression
447 shift_expression .and .loop relational_expression_1;
448 relational_expression_1
449 relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or
450 relational_expression_5;
451 relational_expression_2
452 lessequals .and shift_expression .and .true .emit OP_LESSEQUAL;
453 relational_expression_3
454 greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL;
455 relational_expression_4
456 less .and shift_expression .and .true .emit OP_LESS;
457 relational_expression_5
458 greater .and shift_expression .and .true .emit OP_GREATER;
461 <equality_expression> ::= <relational_expression>
462 | <equality_expression> "==" <relational_expression>
463 | <equality_expression> "!=" <relational_expression>
466 relational_expression .and .loop equality_expression_1;
467 equality_expression_1
468 equality_expression_2 .or equality_expression_3;
469 equality_expression_2
470 equalsequals .and relational_expression .and .true .emit OP_EQUAL;
471 equality_expression_3
472 bangequals .and relational_expression .and .true .emit OP_NOTEQUAL;
475 <and_expression> ::= <equality_expression>
476 | <and_expression> "&" <equality_expression> // reserved
479 equality_expression/* .and .loop and_expression_1*/;
481 ampersand .and equality_expression .and .true .emit OP_BITAND;*/
484 <exclusive_or_expression> ::= <and_expression>
485 | <exclusive_or_expression> "^" <and_expression> // reserved
487 exclusive_or_expression
488 and_expression/* .and .loop exclusive_or_expression_1*/;
489 /*exclusive_or_expression_1
490 caret .and and_expression .and .true .emit OP_BITXOR;*/
493 <inclusive_or_expression> ::= <exclusive_or_expression>
494 | <inclusive_or_expression> "|" <exclusive_or_expression> // reserved
496 inclusive_or_expression
497 exclusive_or_expression/* .and .loop inclusive_or_expression_1*/;
498 /*inclusive_or_expression_1
499 bar .and exclusive_or_expression .and .true .emit OP_BITOR;*/
502 <logical_and_expression> ::= <inclusive_or_expression>
503 | <logical_and_expression> "&&" <inclusive_or_expression>
505 logical_and_expression
506 inclusive_or_expression .and .loop logical_and_expression_1;
507 logical_and_expression_1
508 ampersandampersand .and inclusive_or_expression .and .true .emit OP_LOGICALAND;
511 <logical_xor_expression> ::= <logical_and_expression>
512 | <logical_xor_expression> "^^" <logical_and_expression>
514 logical_xor_expression
515 logical_and_expression .and .loop logical_xor_expression_1;
516 logical_xor_expression_1
517 caretcaret .and logical_and_expression .and .true .emit OP_LOGICALXOR;
520 <logical_or_expression> ::= <logical_xor_expression>
521 | <logical_or_expression> "||" <logical_xor_expression>
523 logical_or_expression
524 logical_xor_expression .and .loop logical_or_expression_1;
525 logical_or_expression_1
526 barbar .and logical_xor_expression .and .true .emit OP_LOGICALOR;
529 <conditional_expression> ::= <logical_or_expression>
530 | <logical_or_expression> "?" <expression> ":"
531 <conditional_expression>
533 conditional_expression
534 logical_or_expression .and .loop conditional_expression_1;
535 conditional_expression_1
536 question .and expression .and colon .and conditional_expression .and .true .emit OP_SELECT;
539 <assignment_expression> ::= <conditional_expression>
540 | <unary_expression> <assignment_operator>
541 <assignment_expression>
543 <assignment_operator> ::= "="
555 assignment_expression
556 assignment_expression_1 .or assignment_expression_2 .or assignment_expression_3 .or
557 assignment_expression_4 .or assignment_expression_5/* .or assignment_expression_6 .or
558 assignment_expression_7 .or assignment_expression_8 .or assignment_expression_9 .or
559 assignment_expression_10 .or assignment_expression_11*/ .or conditional_expression;
560 assignment_expression_1
561 unary_expression .and equals .and assignment_expression .and .true .emit OP_ASSIGN;
562 assignment_expression_2
563 unary_expression .and starequals .and assignment_expression .and .true .emit OP_MULASSIGN;
564 assignment_expression_3
565 unary_expression .and slashequals .and assignment_expression .and .true .emit OP_DIVASSIGN;
566 assignment_expression_4
567 unary_expression .and plusequals .and assignment_expression .and .true .emit OP_ADDASSIGN;
568 assignment_expression_5
569 unary_expression .and minusequals .and assignment_expression .and .true .emit OP_SUBASSIGN;
570 /*assignment_expression_6
571 unary_expression .and percentequals .and assignment_expression .and .true .emit OP_MODASSIGN;*/
572 /*assignment_expression_7
573 unary_expression .and lesslessequals .and assignment_expression .and .true .emit OP_LSHASSIGN;*/
574 /*assignment_expression_8
575 unary_expression .and greatergreaterequals .and assignment_expression .and
576 .true .emit OP_RSHASSIGN;*/
577 /*assignment_expression_9
578 unary_expression .and ampersandequals .and assignment_expression .and .true .emit OP_ANDASSIGN;*/
579 /*assignment_expression_10
580 unary_expression .and caretequals .and assignment_expression .and .true .emit OP_XORASSIGN;*/
581 /*assignment_expression_11
582 unary_expression .and barequals .and assignment_expression .and .true .emit OP_ORASSIGN;*/
585 <expression> ::= <assignment_expression>
586 | <expression> "," <assignment_expression>
589 assignment_expression .and .loop expression_1;
591 comma .and assignment_expression .and .true .emit OP_SEQUENCE;
594 <constant_expression> ::= <conditional_expression>
597 conditional_expression .and .true .emit OP_END;
600 <declaration> ::= <function_prototype> ";"
601 | <init_declarator_list> ";"
604 declaration_1 .or declaration_2;
606 function_prototype .emit DECLARATION_FUNCTION_PROTOTYPE .and semicolon;
608 init_declarator_list .emit DECLARATION_INIT_DECLARATOR_LIST .and semicolon;
611 <function_prototype> ::= <function_header> "void" ")"
612 | <function_declarator> ")"
615 function_prototype_1 .or function_prototype_2;
617 function_header .and "void" .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;
619 function_declarator .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;
622 <function_declarator> ::= <function_header>
623 | <function_header_with_parameters>
626 function_header_with_parameters .or function_header;
629 <function_header_with_parameters> ::= <function_header> <parameter_declaration>
630 | <function_header_with_parameters> ","
631 <parameter_declaration>
633 function_header_with_parameters
634 function_header .and parameter_declaration .and .loop function_header_with_parameters_1;
635 function_header_with_parameters_1
636 comma .and parameter_declaration;
639 <function_header> ::= <fully_specified_type> <identifier> "("
642 function_header_nospace .or function_header_space;
643 function_header_space
644 fully_specified_type_space .and space .and function_decl_identifier .and lparen;
645 function_header_nospace
646 fully_specified_type_nospace .and function_decl_identifier .and lparen;
649 <function_decl_identifier> ::= "__constructor"
653 note: this is an extension to the standard language specification - normally slang disallows
654 operator and constructor prototypes and definitions
656 function_decl_identifier
657 .if (parsing_builtin != 0) __operator .emit FUNCTION_OPERATOR .or
658 .if (parsing_builtin != 0) "__constructor" .emit FUNCTION_CONSTRUCTOR .or
659 identifier .emit FUNCTION_ORDINARY;
662 <__operator> ::= "__operator" <overriden_op>
664 note: this is an extension to the standard language specification - normally slang disallows
665 operator prototypes and definitions
668 "__operator" .and overriden_operator .error INVALID_OPERATOR_OVERRIDE;
671 <overriden_op> ::= "="
704 note: this is an extension to the standard language specification - normally slang disallows
705 operator prototypes and definitions
708 plusplus .emit OPERATOR_INCREMENT .or
709 plusequals .emit OPERATOR_ADDASSIGN .or
710 plus .emit OPERATOR_PLUS .or
711 minusminus .emit OPERATOR_DECREMENT .or
712 minusequals .emit OPERATOR_SUBASSIGN .or
713 minus .emit OPERATOR_MINUS .or
714 bang .emit OPERATOR_NOT .or
715 starequals .emit OPERATOR_MULASSIGN .or
716 star .emit OPERATOR_MULTIPLY .or
717 slashequals .emit OPERATOR_DIVASSIGN .or
718 slash .emit OPERATOR_DIVIDE .or
719 lessequals .emit OPERATOR_LESSEQUAL .or
720 /*lesslessequals .emit OPERATOR_LSHASSIGN .or*/
721 /*lessless .emit OPERATOR_LSHIFT .or*/
722 less .emit OPERATOR_LESS .or
723 greaterequals .emit OPERATOR_GREATEREQUAL .or
724 /*greatergreaterequals .emit OPERATOR_RSHASSIGN .or*/
725 /*greatergreater .emit OPERATOR_RSHIFT .or*/
726 greater .emit OPERATOR_GREATER .or
727 /*percentequals .emit OPERATOR_MODASSIGN .or*/
728 /*percent .emit OPERATOR_MODULUS .or*/
729 /*ampersandequals .emit OPERATOR_ANDASSIGN */
730 /*ampersand .emit OPERATOR_BITAND .or*/
731 /*barequals .emit OPERATOR_ORASSIGN .or*/
732 /*bar .emit OPERATOR_BITOR .or*/
733 /*tilde .emit OPERATOR_COMPLEMENT .or*/
734 /*caretequals .emit OPERATOR_XORASSIGN .or*/
735 caretcaret .emit OPERATOR_LOGICALXOR /*.or
736 caret .emit OPERATOR_BITXOR*/;
739 <parameter_declarator> ::= <type_specifier> <identifier>
740 | <type_specifier> <identifier> "[" <constant_expression>
744 parameter_declarator_nospace .or parameter_declarator_space;
745 parameter_declarator_nospace
746 type_specifier_nospace .and identifier .and parameter_declarator_1;
747 parameter_declarator_space
748 type_specifier_space .and space .and identifier .and parameter_declarator_1;
749 parameter_declarator_1
750 parameter_declarator_2 .emit PARAMETER_ARRAY_PRESENT .or
751 .true .emit PARAMETER_ARRAY_NOT_PRESENT;
752 parameter_declarator_2
753 lbracket .and constant_expression .and rbracket;
756 <parameter_declaration> ::= <type_qualifier> <parameter_qualifier>
757 <precision> <parameter_declarator>
758 | <type_qualifier> <parameter_qualifier>
759 <precision> <parameter_type_specifier>
760 | <type_qualifier> <parameter_qualifier>
761 <parameter_declarator>
762 | <type_qualifier> <parameter_qualifier>
763 <parameter_type_specifier>
764 | <parameter_qualifier> <precision>
765 <parameter_declarator>
766 | <parameter_qualifier> <precision>
767 <parameter_type_specifier>
768 | <parameter_qualifier> <parameter_declarator>
769 | <parameter_qualifier> <parameter_type_specifier>
771 parameter_declaration
772 parameter_declaration_1 .emit PARAMETER_NEXT;
773 parameter_declaration_1
774 parameter_declaration_2 .or parameter_declaration_3;
775 parameter_declaration_2
776 type_qualifier .and space .and parameter_qualifier .and parameter_declaration_4;
777 parameter_declaration_3
778 parameter_qualifier .emit TYPE_QUALIFIER_NONE .and parameter_declaration_4;
779 parameter_declaration_4
780 parameter_declaration_optprec .and parameter_declaration_rest;
781 parameter_declaration_optprec
782 parameter_declaration_prec .or .true .emit PRECISION_DEFAULT;
783 parameter_declaration_prec
784 precision .and space;
785 parameter_declaration_rest
786 parameter_declarator .or parameter_type_specifier;
789 <parameter_qualifier> ::= "in"
795 parameter_qualifier_1 .or .true .emit PARAM_QUALIFIER_IN;
796 parameter_qualifier_1
797 parameter_qualifier_2 .and space;
798 parameter_qualifier_2
799 "in" .emit PARAM_QUALIFIER_IN .or
800 "out" .emit PARAM_QUALIFIER_OUT .or
801 "inout" .emit PARAM_QUALIFIER_INOUT;
804 <parameter_type_specifier> ::= <type_specifier>
805 | <type_specifier> "[" <constant_expression> "]"
807 parameter_type_specifier
808 parameter_type_specifier_1 .and .true .emit '\0' .and parameter_type_specifier_2;
809 parameter_type_specifier_1
810 type_specifier_nospace .or type_specifier_space;
811 parameter_type_specifier_2
812 parameter_type_specifier_3 .emit PARAMETER_ARRAY_PRESENT .or
813 .true .emit PARAMETER_ARRAY_NOT_PRESENT;
814 parameter_type_specifier_3
815 lbracket .and constant_expression .and rbracket;
818 <init_declarator_list> ::= <single_declaration>
819 | <init_declarator_list> "," <identifier>
820 | <init_declarator_list> "," <identifier> "[" "]"
821 | <init_declarator_list> "," <identifier> "["
822 <constant_expression> "]"
823 | <init_declarator_list> "," <identifier> "="
827 single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and
828 .true .emit DECLARATOR_NONE;
829 init_declarator_list_1
830 comma .and identifier .emit VARIABLE_IDENTIFIER .and init_declarator_list_2;
831 init_declarator_list_2
832 init_declarator_list_3 .or init_declarator_list_4 .or .true .emit VARIABLE_NONE;
833 init_declarator_list_3
834 equals .and initializer .emit VARIABLE_INITIALIZER;
835 init_declarator_list_4
836 lbracket .and init_declarator_list_5 .and rbracket;
837 init_declarator_list_5
838 constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
841 <single_declaration> ::= <fully_specified_type>
842 | <fully_specified_type> <identifier>
843 | <fully_specified_type> <identifier> "[" "]"
844 | <fully_specified_type> <identifier> "["
845 <constant_expression> "]"
846 | <fully_specified_type> <identifier> "=" <initializer>
849 single_declaration_nospace .or single_declaration_space;
850 single_declaration_space
851 fully_specified_type_space .and single_declaration_space_1;
852 single_declaration_nospace
853 fully_specified_type_nospace .and single_declaration_nospace_1;
854 single_declaration_space_1
855 single_declaration_space_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
856 single_declaration_nospace_1
857 single_declaration_nospace_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
858 single_declaration_space_2
859 space .and identifier .and single_declaration_3;
860 single_declaration_nospace_2
861 identifier .and single_declaration_3;
863 single_declaration_4 .or single_declaration_5 .or .true .emit VARIABLE_NONE;
865 equals .and initializer .emit VARIABLE_INITIALIZER;
867 lbracket .and single_declaration_6 .and rbracket;
869 constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
872 <fully_specified_type> ::= <type_specifier>
873 | <type_qualifier> <type_specifier>
874 | <precision> <type_specifier>
875 | <type_qualifier> <precision> <type_specifier>
877 fully_specified_type_space
878 fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;
879 fully_specified_type_nospace
880 fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;
881 fully_specified_type_optqual
882 fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;
883 fully_specified_type_qual
884 type_qualifier .and space;
885 fully_specified_type_optprec
886 fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;
887 fully_specified_type_prec
888 precision .and space;
891 <type_qualifier> ::= "const"
892 | "attribute" // Vertex only.
898 note: this is an extension to the standard language specification - normally slang disallows
899 __fixed_output and __fixed_input type qualifiers
902 "const" .emit TYPE_QUALIFIER_CONST .or
903 .if (shader_type == 2) "attribute" .emit TYPE_QUALIFIER_ATTRIBUTE .or
904 "varying" .emit TYPE_QUALIFIER_VARYING .or
905 "uniform" .emit TYPE_QUALIFIER_UNIFORM .or
906 .if (parsing_builtin != 0) "__fixed_output" .emit TYPE_QUALIFIER_FIXEDOUTPUT .or
907 .if (parsing_builtin != 0) "__fixed_input" .emit TYPE_QUALIFIER_FIXEDINPUT;
910 <type_specifier> ::= "void"
939 | "sampler2DRectShadow"
944 "void" .emit TYPE_SPECIFIER_VOID .or
945 "float" .emit TYPE_SPECIFIER_FLOAT .or
946 "int" .emit TYPE_SPECIFIER_INT .or
947 "bool" .emit TYPE_SPECIFIER_BOOL .or
948 "vec2" .emit TYPE_SPECIFIER_VEC2 .or
949 "vec3" .emit TYPE_SPECIFIER_VEC3 .or
950 "vec4" .emit TYPE_SPECIFIER_VEC4 .or
951 "bvec2" .emit TYPE_SPECIFIER_BVEC2 .or
952 "bvec3" .emit TYPE_SPECIFIER_BVEC3 .or
953 "bvec4" .emit TYPE_SPECIFIER_BVEC4 .or
954 "ivec2" .emit TYPE_SPECIFIER_IVEC2 .or
955 "ivec3" .emit TYPE_SPECIFIER_IVEC3 .or
956 "ivec4" .emit TYPE_SPECIFIER_IVEC4 .or
957 "mat2" .emit TYPE_SPECIFIER_MAT2 .or
958 "mat3" .emit TYPE_SPECIFIER_MAT3 .or
959 "mat4" .emit TYPE_SPECIFIER_MAT4 .or
960 "mat2x3" .emit TYPE_SPECIFIER_MAT23 .or
961 "mat3x2" .emit TYPE_SPECIFIER_MAT32 .or
962 "mat2x4" .emit TYPE_SPECIFIER_MAT24 .or
963 "mat4x2" .emit TYPE_SPECIFIER_MAT42 .or
964 "mat3x4" .emit TYPE_SPECIFIER_MAT34 .or
965 "mat4x3" .emit TYPE_SPECIFIER_MAT43 .or
966 "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
967 "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
968 "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
969 "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
970 "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
971 "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
972 "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
973 "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or
974 type_name .emit TYPE_SPECIFIER_TYPENAME;
975 type_specifier_nospace
976 struct_specifier .emit TYPE_SPECIFIER_STRUCT;
979 <struct_specifier> ::= "struct" <identifier> "{" <struct_declaration_list> "}"
980 | "struct" "{" <struct_declaration_list> "}"
983 "struct" .and struct_specifier_1 .and optional_space .and lbrace .error LBRACE_EXPECTED .and
984 struct_declaration_list .and rbrace .emit FIELD_NONE;
986 struct_specifier_2 .or .true .emit '\0';
988 space .and identifier;
991 <struct_declaration_list> ::= <struct_declaration>
992 | <struct_declaration_list> <struct_declaration>
994 struct_declaration_list
995 struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;
998 <struct_declaration> ::= <type_specifier> <struct_declarator_list> ";"
1001 struct_declaration_nospace .or struct_declaration_space;
1002 struct_declaration_space
1003 type_specifier_space .and space .and struct_declarator_list .and semicolon .emit FIELD_NONE;
1004 struct_declaration_nospace
1005 type_specifier_nospace .and struct_declarator_list .and semicolon .emit FIELD_NONE;
1008 <struct_declarator_list> ::= <struct_declarator>
1009 | <struct_declarator_list> "," <struct_declarator>
1011 struct_declarator_list
1012 struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT;
1013 struct_declarator_list_1
1014 comma .and struct_declarator;
1017 <struct_declarator> ::= <identifier>
1018 | <identifier> "[" <constant_expression> "]"
1021 identifier .and struct_declarator_1;
1023 struct_declarator_2 .emit FIELD_ARRAY .or .true .emit FIELD_NONE;
1025 lbracket .and constant_expression .and rbracket;
1028 <initializer> ::= <assignment_expression>
1031 assignment_expression .and .true .emit OP_END;
1034 <declaration_statement> ::= <declaration>
1036 declaration_statement
1040 <statement> ::= <compound_statement>
1041 | <simple_statement>
1044 compound_statement .or simple_statement;
1046 compound_statement .or statement_space_1;
1048 space .and simple_statement;
1051 <simple_statement> ::= <__asm_statement>
1052 | <selection_statement>
1053 | <iteration_statement>
1055 | <expression_statement>
1056 | <declaration_statement>
1058 note: this is an extension to the standard language specification - normally slang disallows
1059 use of __asm statements
1062 .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or
1063 selection_statement .or
1064 iteration_statement .or
1065 precision_stmt .emit OP_PRECISION .or
1067 expression_statement .emit OP_EXPRESSION .or
1068 declaration_statement .emit OP_DECLARE;
1071 <compound_statement> ::= "{" "}"
1072 | "{" <statement_list> "}"
1075 compound_statement_1 .emit OP_BLOCK_BEGIN_NEW_SCOPE .and .true .emit OP_END;
1076 compound_statement_1
1077 compound_statement_2 .or compound_statement_3;
1078 compound_statement_2
1080 compound_statement_3
1081 lbrace .and statement_list .and rbrace;
1084 <statement_no_new_scope> ::= <compound_statement_no_new_scope>
1085 | <simple_statement>
1087 statement_no_new_scope
1088 compound_statement_no_new_scope .or simple_statement;
1091 <compound_statement_no_new_scope> ::= "{" "}"
1092 | "{" <statement_list> "}"
1094 compound_statement_no_new_scope
1095 compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;
1096 compound_statement_no_new_scope_1
1097 compound_statement_no_new_scope_2 .or compound_statement_no_new_scope_3;
1098 compound_statement_no_new_scope_2
1100 compound_statement_no_new_scope_3
1101 lbrace .and statement_list .and rbrace;
1104 <statement_list> ::= <statement>
1105 | <statement_list> <statement>
1108 statement .and .loop statement;
1111 <expression_statement> ::= ";"
1114 expression_statement
1115 expression_statement_1 .or expression_statement_2;
1116 expression_statement_1
1117 semicolon .emit OP_PUSH_VOID .emit OP_END;
1118 expression_statement_2
1119 expression .and semicolon .emit OP_END;
1122 <selection_statement> ::= "if" "(" <expression> ")" <selection_rest_statement>
1125 "if" .emit OP_IF .and lparen .error LPAREN_EXPECTED .and expression .and
1126 rparen .error RPAREN_EXPECTED .emit OP_END .and selection_rest_statement;
1129 <selection_rest_statement> ::= <statement> "else" <statement>
1132 selection_rest_statement
1133 statement .and selection_rest_statement_1;
1134 selection_rest_statement_1
1135 selection_rest_statement_2 .or .true .emit OP_EXPRESSION .emit OP_PUSH_VOID .emit OP_END;
1136 selection_rest_statement_2
1137 "else" .and optional_space .and statement;
1140 <condition> ::= <expression>
1141 | <fully_specified_type> <identifier> "=" <initializer>
1143 note: if <condition_1> is executed, the emit format must match <declaration> emit format
1146 condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or
1147 condition_3 .emit OP_EXPRESSION;
1149 condition_1_nospace .or condition_1_space;
1151 fully_specified_type_nospace .and condition_2;
1153 fully_specified_type_space .and space .and condition_2;
1155 identifier .emit VARIABLE_IDENTIFIER .and equals .emit VARIABLE_INITIALIZER .and
1156 initializer .and .true .emit DECLARATOR_NONE;
1158 expression .and .true .emit OP_END;
1161 <iteration_statement> ::= "while" "(" <condition> ")" <statement>
1162 | "do" <statement> "while" "(" <expression> ")" ";"
1163 | "for" "(" <for_init_statement> <for_rest_statement> ")"
1164 <statement_no_new_scope>
1167 iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;
1168 iteration_statement_1
1169 "while" .emit OP_WHILE .and lparen .error LPAREN_EXPECTED .and condition .and
1170 rparen .error RPAREN_EXPECTED .and statement;
1171 iteration_statement_2
1172 "do" .emit OP_DO .and statement_space .and "while" .and lparen .error LPAREN_EXPECTED .and
1173 expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;
1174 iteration_statement_3
1175 "for" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and
1176 for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement_no_new_scope;
1179 <for_init_statement> ::= <expression_statement>
1180 | <declaration_statement>
1183 expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;
1186 <conditionopt> ::= <condition>
1189 note: <conditionopt> is used only by "for" statement - if <condition> is ommitted, parser
1190 simulates default behaviour, that is simulates "true" expression
1194 .true .emit OP_EXPRESSION .emit OP_PUSH_BOOL .emit 2 .emit '1' .emit '\0' .emit OP_END;
1197 <for_rest_statement> ::= <conditionopt> ";"
1198 | <conditionopt> ";" <expression>
1201 conditionopt .and semicolon .and for_rest_statement_1;
1202 for_rest_statement_1
1203 for_rest_statement_2 .or .true .emit OP_PUSH_VOID .emit OP_END;
1204 for_rest_statement_2
1205 expression .and .true .emit OP_END;
1208 <jump_statement> ::= "continue" ";"
1211 | "return" <expression> ";"
1212 | "discard" ";" // Fragment shader only.
1215 jump_statement_1 .or jump_statement_2 .or jump_statement_3 .or jump_statement_4 .or
1216 .if (shader_type == 1) jump_statement_5;
1218 "continue" .and semicolon .emit OP_CONTINUE;
1220 "break" .and semicolon .emit OP_BREAK;
1222 "return" .emit OP_RETURN .and optional_space .and expression .and semicolon .emit OP_END;
1224 "return" .emit OP_RETURN .and semicolon .emit OP_PUSH_VOID .emit OP_END;
1226 "discard" .and semicolon .emit OP_DISCARD;
1229 <__asm_statement> ::= "__asm" <identifier> <asm_arguments> ";"
1231 note: this is an extension to the standard language specification - normally slang disallows
1235 "__asm" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;
1238 <asm_arguments> ::= <asm_argument>
1239 | <asm_arguments> "," <asm_argument>
1241 note: this is an extension to the standard language specification - normally slang disallows
1245 asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;
1247 comma .and asm_argument .and .true .emit OP_END;
1250 <asm_argument> ::= <variable_identifier>
1253 note: this is an extension to the standard language specification - normally slang disallows
1258 variable_identifier .or
1262 variable_identifier .and dot .and field_selection .emit OP_FIELD;
1266 * <translation_unit> ::= <external_declaration>
1267 * | <translation_unit> <external_declaration>
1270 optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and
1271 .loop external_declaration .and optional_space .and
1272 '\0' .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;
1276 * <external_declaration> ::= <function_definition>
1279 external_declaration
1280 precision_stmt .emit DEFAULT_PRECISION .or
1281 invariant_stmt .emit INVARIANT_STMT .or
1282 function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or
1283 declaration .emit EXTERNAL_DECLARATION;
1287 * <precision_stmt> ::= "precision" <precision> <prectype>
1290 "precision" .and space .and precision .error INVALID_PRECISION .and space .and prectype .error INVALID_PRECISION_TYPE .and semicolon;
1293 * <precision> ::= "lowp"
1298 "lowp" .emit PRECISION_LOW .or
1299 "mediump" .emit PRECISION_MEDIUM .or
1300 "highp" .emit PRECISION_HIGH;
1303 * <prectype> ::= "int"
1305 * | "a sampler type"
1308 "int" .emit TYPE_SPECIFIER_INT .or
1309 "float" .emit TYPE_SPECIFIER_FLOAT .or
1310 "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
1311 "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
1312 "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
1313 "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
1314 "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
1315 "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
1316 "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
1317 "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW;
1321 * <invariant_stmt> ::= "invariant" identifier;
1324 "invariant" .and space .and identifier .and semicolon;
1329 <function_definition> :: <function_prototype> <compound_statement_no_new_scope>
1332 function_prototype .and compound_statement_no_new_scope;
1334 /* helper rulez, not part of the official language syntax */
1343 '0'-'9' .or 'A'-'F' .or 'a'-'f';
1346 'a'-'z' .or 'A'-'Z' .or '_';
1349 id_character_first .or digit_dec;
1352 id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\0';
1355 float_1 .or float_2;
1357 float_fractional_constant .and float_optional_exponent_part;
1359 float_digit_sequence .and .true .emit '\0' .and float_exponent_part;
1361 float_fractional_constant
1362 float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;
1363 float_fractional_constant_1
1364 float_digit_sequence .and '.' .and float_digit_sequence;
1365 float_fractional_constant_2
1366 float_digit_sequence .and '.' .and .true .emit '\0';
1367 float_fractional_constant_3
1368 '.' .emit '\0' .and float_digit_sequence;
1370 float_optional_exponent_part
1371 float_exponent_part .or .true .emit '\0';
1373 float_digit_sequence
1374 digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
1377 float_exponent_part_1 .or float_exponent_part_2;
1378 float_exponent_part_1
1379 'e' .and float_optional_sign .and float_digit_sequence;
1380 float_exponent_part_2
1381 'E' .and float_optional_sign .and float_digit_sequence;
1384 float_sign .or .true;
1387 '+' .or '-' .emit '-';
1390 integer_hex .or integer_oct .or integer_dec;
1393 '0' .and integer_hex_1 .emit 0x10 .and digit_hex .emit * .and .loop digit_hex .emit * .and
1399 '0' .emit 8 .emit * .and .loop digit_oct .emit * .and .true .emit '\0';
1402 digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
1405 "true" .emit 2 .emit '1' .emit '\0' .or
1406 "false" .emit 2 .emit '0' .emit '\0';
1415 float .emit OP_PUSH_FLOAT;
1418 integer .emit OP_PUSH_INT;
1421 boolean .emit OP_PUSH_BOOL;
1427 single_space .and .loop single_space;
1430 white_char .or c_style_comment_block .or cpp_style_comment_block;
1433 ' ' .or '\t' .or new_line .or '\v' .or '\f';
1436 cr_lf .or lf_cr .or '\n' .or '\r';
1444 c_style_comment_block
1445 '/' .and '*' .and c_style_comment_rest;
1447 c_style_comment_rest
1448 .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
1449 c_style_comment_rest_1
1450 c_style_comment_end .or c_style_comment_rest_2;
1451 c_style_comment_rest_2
1452 '*' .and c_style_comment_rest;
1454 c_style_comment_char_no_star
1455 '\x2B'-'\xFF' .or '\x01'-'\x29';
1460 cpp_style_comment_block
1461 '/' .and '/' .and cpp_style_comment_block_1;
1462 cpp_style_comment_block_1
1463 cpp_style_comment_block_2 .or cpp_style_comment_block_3;
1464 cpp_style_comment_block_2
1465 .loop cpp_style_comment_char .and new_line;
1466 cpp_style_comment_block_3
1467 .loop cpp_style_comment_char;
1469 cpp_style_comment_char
1470 '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
1475 optional_space .and '&' .and optional_space;*/
1478 optional_space .and '&' .and '&' .and optional_space;
1481 optional_space .and '&' .and '=' .and optional_space;*/
1484 optional_space .and '|' .and optional_space;*/
1487 optional_space .and '|' .and '|' .and optional_space;
1490 optional_space .and '|' .and '=' .and optional_space;*/
1493 optional_space .and '!' .and optional_space;
1496 optional_space .and '!' .and '=' .and optional_space;
1499 optional_space .and '^' .and optional_space;*/
1502 optional_space .and '^' .and '^' .and optional_space;
1505 optional_space .and '^' .and '=' .and optional_space;*/
1508 optional_space .and ':' .and optional_space;
1511 optional_space .and ',' .and optional_space;
1514 optional_space .and '.' .and optional_space;
1517 optional_space .and '=' .and optional_space;
1520 optional_space .and '=' .and '=' .and optional_space;
1523 optional_space .and '>' .and optional_space;
1526 optional_space .and '>' .and '=' .and optional_space;
1529 optional_space .and '>' .and '>' .and optional_space;*/
1531 /*greatergreaterequals
1532 optional_space .and '>' .and '>' .and '=' .and optional_space;*/
1535 optional_space .and '{' .and optional_space;
1538 optional_space .and '[' .and optional_space;
1541 optional_space .and '<' .and optional_space;
1544 optional_space .and '<' .and '=' .and optional_space;
1547 optional_space .and '<' .and '<' .and optional_space;*/
1550 optional_space .and '<' .and '<' .and '=' .and optional_space;*/
1553 optional_space .and '(' .and optional_space;
1556 optional_space .and '-' .and optional_space;
1559 optional_space .and '-' .and '=' .and optional_space;
1562 optional_space .and '-' .and '-' .and optional_space;
1565 optional_space .and '%' .and optional_space;*/
1568 optional_space .and '%' .and '=' .and optional_space;*/
1571 optional_space .and '+' .and optional_space;
1574 optional_space .and '+' .and '=' .and optional_space;
1577 optional_space .and '+' .and '+' .and optional_space;
1580 optional_space .and '?' .and optional_space;
1583 optional_space .and '}' .and optional_space;
1586 optional_space .and ']' .and optional_space;
1589 optional_space .and ')' .and optional_space;
1592 optional_space .and ';' .and optional_space;
1595 optional_space .and '/' .and optional_space;
1598 optional_space .and '/' .and '=' .and optional_space;
1601 optional_space .and '*' .and optional_space;
1604 optional_space .and '*' .and '=' .and optional_space;
1607 optional_space .and '~' .and optional_space;*/
1609 /* string rulez - these are used internally by the parser when parsing quoted strings */
1611 .string string_lexer;
1614 lex_first_identifier_character .and .loop lex_next_identifier_character;
1616 lex_first_identifier_character
1617 'a'-'z' .or 'A'-'Z' .or '_';
1619 lex_next_identifier_character
1620 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
1622 /* error rulez - these are used by error messages */
1625 '~' .or '`' .or '!' .or '@' .or '#' .or '$' .or '%' .or '^' .or '&' .or '*' .or '(' .or ')' .or
1626 '-' .or '+' .or '=' .or '|' .or '\\' .or '[' .or ']' .or '{' .or '}' .or ':' .or ';' .or '"' .or
1627 '\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;
1630 id_character_first .and .loop id_character_next;