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
138 .emtcode TYPE_SPECIFIER_VOID 0
139 .emtcode TYPE_SPECIFIER_BOOL 1
140 .emtcode TYPE_SPECIFIER_BVEC2 2
141 .emtcode TYPE_SPECIFIER_BVEC3 3
142 .emtcode TYPE_SPECIFIER_BVEC4 4
143 .emtcode TYPE_SPECIFIER_INT 5
144 .emtcode TYPE_SPECIFIER_IVEC2 6
145 .emtcode TYPE_SPECIFIER_IVEC3 7
146 .emtcode TYPE_SPECIFIER_IVEC4 8
147 .emtcode TYPE_SPECIFIER_FLOAT 9
148 .emtcode TYPE_SPECIFIER_VEC2 10
149 .emtcode TYPE_SPECIFIER_VEC3 11
150 .emtcode TYPE_SPECIFIER_VEC4 12
151 .emtcode TYPE_SPECIFIER_MAT2 13
152 .emtcode TYPE_SPECIFIER_MAT3 14
153 .emtcode TYPE_SPECIFIER_MAT4 15
154 .emtcode TYPE_SPECIFIER_SAMPLER1D 16
155 .emtcode TYPE_SPECIFIER_SAMPLER2D 17
156 .emtcode TYPE_SPECIFIER_SAMPLER3D 18
157 .emtcode TYPE_SPECIFIER_SAMPLERCUBE 19
158 .emtcode TYPE_SPECIFIER_SAMPLER1DSHADOW 20
159 .emtcode TYPE_SPECIFIER_SAMPLER2DSHADOW 21
160 .emtcode TYPE_SPECIFIER_SAMPLER2DRECT 22
161 .emtcode TYPE_SPECIFIER_SAMPLER2DRECTSHADOW 23
162 .emtcode TYPE_SPECIFIER_STRUCT 24
163 .emtcode TYPE_SPECIFIER_TYPENAME 25
166 .emtcode TYPE_SPECIFIER_MAT23 26
167 .emtcode TYPE_SPECIFIER_MAT32 27
168 .emtcode TYPE_SPECIFIER_MAT24 28
169 .emtcode TYPE_SPECIFIER_MAT42 29
170 .emtcode TYPE_SPECIFIER_MAT34 30
171 .emtcode TYPE_SPECIFIER_MAT43 31
174 /* structure field */
175 .emtcode FIELD_NONE 0
176 .emtcode FIELD_NEXT 1
177 .emtcode FIELD_ARRAY 2
181 .emtcode OP_BLOCK_BEGIN_NO_NEW_SCOPE 1
182 .emtcode OP_BLOCK_BEGIN_NEW_SCOPE 2
183 .emtcode OP_DECLARE 3
186 .emtcode OP_CONTINUE 6
187 .emtcode OP_DISCARD 7
189 .emtcode OP_EXPRESSION 9
194 .emtcode OP_PUSH_VOID 14
195 .emtcode OP_PUSH_BOOL 15
196 .emtcode OP_PUSH_INT 16
197 .emtcode OP_PUSH_FLOAT 17
198 .emtcode OP_PUSH_IDENTIFIER 18
199 .emtcode OP_SEQUENCE 19
200 .emtcode OP_ASSIGN 20
201 .emtcode OP_ADDASSIGN 21
202 .emtcode OP_SUBASSIGN 22
203 .emtcode OP_MULASSIGN 23
204 .emtcode OP_DIVASSIGN 24
205 /*.emtcode OP_MODASSIGN 25*/
206 /*.emtcode OP_LSHASSIGN 26*/
207 /*.emtcode OP_RSHASSIGN 27*/
208 /*.emtcode OP_ORASSIGN 28*/
209 /*.emtcode OP_XORASSIGN 29*/
210 /*.emtcode OP_ANDASSIGN 30*/
211 .emtcode OP_SELECT 31
212 .emtcode OP_LOGICALOR 32
213 .emtcode OP_LOGICALXOR 33
214 .emtcode OP_LOGICALAND 34
215 /*.emtcode OP_BITOR 35*/
216 /*.emtcode OP_BITXOR 36*/
217 /*.emtcode OP_BITAND 37*/
219 .emtcode OP_NOTEQUAL 39
221 .emtcode OP_GREATER 41
222 .emtcode OP_LESSEQUAL 42
223 .emtcode OP_GREATEREQUAL 43
224 /*.emtcode OP_LSHIFT 44*/
225 /*.emtcode OP_RSHIFT 45*/
227 .emtcode OP_SUBTRACT 47
228 .emtcode OP_MULTIPLY 48
229 .emtcode OP_DIVIDE 49
230 /*.emtcode OP_MODULUS 50*/
231 .emtcode OP_PREINCREMENT 51
232 .emtcode OP_PREDECREMENT 52
235 /*.emtcode OP_COMPLEMENT 55*/
237 .emtcode OP_SUBSCRIPT 57
240 .emtcode OP_POSTINCREMENT 60
241 .emtcode OP_POSTDECREMENT 61
242 .emtcode OP_PRECISION 62
244 /* parameter qualifier */
245 .emtcode PARAM_QUALIFIER_IN 0
246 .emtcode PARAM_QUALIFIER_OUT 1
247 .emtcode PARAM_QUALIFIER_INOUT 2
249 /* function parameter */
250 .emtcode PARAMETER_NONE 0
251 .emtcode PARAMETER_NEXT 1
253 /* function parameter array presence */
254 .emtcode PARAMETER_ARRAY_NOT_PRESENT 0
255 .emtcode PARAMETER_ARRAY_PRESENT 1
257 /* INVALID_EXTERNAL_DECLARATION seems to be reported when there's */
258 /* any syntax errors... */
259 .errtext INVALID_EXTERNAL_DECLARATION "2001: Syntax error."
260 .errtext INVALID_OPERATOR_OVERRIDE "2002: Invalid operator override."
261 .errtext LBRACE_EXPECTED "2003: '{' expected but '$err_token$' found."
262 .errtext LPAREN_EXPECTED "2004: '(' expected but '$err_token$' found."
263 .errtext RPAREN_EXPECTED "2005: ')' expected but '$err_token$' found."
264 .errtext INVALID_PRECISION "2006: Invalid precision specifier '$err_token$'."
265 .errtext INVALID_PRECISION_TYPE "2007: Invalid precision type '$err_token$'."
269 * tells whether the shader that is being parsed is a built-in shader or not
270 * 0 - normal behaviour
271 * 1 - accepts constructor and operator definitions and __asm statements
272 * the implementation will set it to 1 when compiling internal built-in shaders
274 .regbyte parsing_builtin 0
277 * holds the type of the shader being parsed; possible values are
281 * shader type is set by the caller before parsing
283 .regbyte shader_type 0
286 * <variable_identifier> ::= <identifier>
289 identifier .emit OP_PUSH_IDENTIFIER;
292 * <primary_expression> ::= <variable_identifier>
296 * | "(" <expression> ")"
299 floatconstant .or boolconstant .or intconstant .or variable_identifier .or primary_expression_1;
301 lparen .and expression .and rparen;
304 * <postfix_expression> ::= <primary_expression>
305 * | <postfix_expression> "[" <integer_expression> "]"
307 * | <postfix_expression> "." <field_selection>
308 * | <postfix_expression> "++"
309 * | <postfix_expression> "--"
312 postfix_expression_1 .and .loop postfix_expression_2;
314 function_call .or primary_expression;
316 postfix_expression_3 .or postfix_expression_4 .or
317 plusplus .emit OP_POSTINCREMENT .or
318 minusminus .emit OP_POSTDECREMENT;
320 lbracket .and integer_expression .and rbracket .emit OP_SUBSCRIPT;
322 dot .and field_selection .emit OP_FIELD;
325 * <integer_expression> ::= <expression>
331 * <function_call> ::= <function_call_generic>
334 function_call_generic .emit OP_CALL .and .true .emit OP_END;
337 * <function_call_generic> ::= <function_call_header_with_parameters> ")"
338 * | <function_call_header_no_parameters> ")"
340 function_call_generic
341 function_call_generic_1 .or function_call_generic_2;
342 function_call_generic_1
343 function_call_header_with_parameters .and rparen .error RPAREN_EXPECTED;
344 function_call_generic_2
345 function_call_header_no_parameters .and rparen .error RPAREN_EXPECTED;
348 * <function_call_header_no_parameters>::= <function_call_header> "void"
349 * | <function_call_header>
351 function_call_header_no_parameters
352 function_call_header .and function_call_header_no_parameters_1;
353 function_call_header_no_parameters_1
357 * <function_call_header_with_parameters> ::= <function_call_header> <assignment_expression>
358 * | <function_call_header_with_parameters> "," <assignment_expression>
360 function_call_header_with_parameters
361 function_call_header .and assignment_expression .and .true .emit OP_END .and
362 .loop function_call_header_with_parameters_1;
363 function_call_header_with_parameters_1
364 comma .and assignment_expression .and .true .emit OP_END;
367 * <function_call_header> ::= <function_identifier> "("
370 function_identifier .and lparen;
373 * <function_identifier> ::= <constructor_identifier>
376 * note: <constructor_identifier> has been deleted
382 * <unary_expression> ::= <postfix_expression>
383 * | "++" <unary_expression>
384 * | "--" <unary_expression>
385 * | <unary_operator> <unary_expression>
387 * <unary_operator> ::= "+"
393 postfix_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or
394 unary_expression_4 .or unary_expression_5/* .or unary_expression_6*/;
396 plusplus .and unary_expression .and .true .emit OP_PREINCREMENT;
398 minusminus .and unary_expression .and .true .emit OP_PREDECREMENT;
400 plus .and unary_expression .and .true .emit OP_PLUS;
402 minus .and unary_expression .and .true .emit OP_MINUS;
404 bang .and unary_expression .and .true .emit OP_NOT;
406 tilde .and unary_expression .and .true .emit OP_COMPLEMENT;*/
409 * <multiplicative_expression> ::= <unary_expression>
410 * | <multiplicative_expression> "*" <unary_expression>
411 * | <multiplicative_expression> "/" <unary_expression>
412 * | <multiplicative_expression> "%" <unary_expression> // reserved
414 multiplicative_expression
415 unary_expression .and .loop multiplicative_expression_1;
416 multiplicative_expression_1
417 multiplicative_expression_2 .or multiplicative_expression_3/* .or multiplicative_expression_4*/;
418 multiplicative_expression_2
419 star .and unary_expression .and .true .emit OP_MULTIPLY;
420 multiplicative_expression_3
421 slash .and unary_expression .and .true .emit OP_DIVIDE;
422 /*multiplicative_expression_4
423 percent .and unary_expression .and .true .emit OP_MODULUS;*/
426 * <additive_expression> ::= <multiplicative_expression>
427 * | <additive_expression> "+" <multiplicative_expression>
428 * | <additive_expression> "-" <multiplicative_expression>
431 multiplicative_expression .and .loop additive_expression_1;
432 additive_expression_1
433 additive_expression_2 .or additive_expression_3;
434 additive_expression_2
435 plus .and multiplicative_expression .and .true .emit OP_ADD;
436 additive_expression_3
437 minus .and multiplicative_expression .and .true .emit OP_SUBTRACT;
440 * <shift_expression> ::= <additive_expression>
441 * | <shift_expression> "<<" <additive_expression> // reserved
442 * | <shift_expression> ">>" <additive_expression> // reserved
445 additive_expression/* .and .loop shift_expression_1*/;
447 shift_expression_2 .or shift_expression_3;*/
449 lessless .and additive_expression .and .true .emit OP_LSHIFT;*/
451 greatergreater .and additive_expression .and .true .emit OP_RSHIFT;*/
454 * <relational_expression> ::= <shift_expression>
455 * | <relational_expression> "<" <shift_expression>
456 * | <relational_expression> ">" <shift_expression>
457 * | <relational_expression> "<=" <shift_expression>
458 * | <relational_expression> ">=" <shift_expression>
460 relational_expression
461 shift_expression .and .loop relational_expression_1;
462 relational_expression_1
463 relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or
464 relational_expression_5;
465 relational_expression_2
466 lessequals .and shift_expression .and .true .emit OP_LESSEQUAL;
467 relational_expression_3
468 greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL;
469 relational_expression_4
470 less .and shift_expression .and .true .emit OP_LESS;
471 relational_expression_5
472 greater .and shift_expression .and .true .emit OP_GREATER;
475 * <equality_expression> ::= <relational_expression>
476 * | <equality_expression> "==" <relational_expression>
477 * | <equality_expression> "!=" <relational_expression>
480 relational_expression .and .loop equality_expression_1;
481 equality_expression_1
482 equality_expression_2 .or equality_expression_3;
483 equality_expression_2
484 equalsequals .and relational_expression .and .true .emit OP_EQUAL;
485 equality_expression_3
486 bangequals .and relational_expression .and .true .emit OP_NOTEQUAL;
489 * <and_expression> ::= <equality_expression>
490 * | <and_expression> "&" <equality_expression> // reserved
493 equality_expression/* .and .loop and_expression_1*/;
495 ampersand .and equality_expression .and .true .emit OP_BITAND;*/
498 * <exclusive_or_expression> ::= <and_expression>
499 * | <exclusive_or_expression> "^" <and_expression> // reserved
501 exclusive_or_expression
502 and_expression/* .and .loop exclusive_or_expression_1*/;
503 /*exclusive_or_expression_1
504 caret .and and_expression .and .true .emit OP_BITXOR;*/
507 * <inclusive_or_expression> ::= <exclusive_or_expression>
508 * | <inclusive_or_expression> "|" <exclusive_or_expression> // reserved
510 inclusive_or_expression
511 exclusive_or_expression/* .and .loop inclusive_or_expression_1*/;
512 /*inclusive_or_expression_1
513 bar .and exclusive_or_expression .and .true .emit OP_BITOR;*/
516 * <logical_and_expression> ::= <inclusive_or_expression>
517 * | <logical_and_expression> "&&" <inclusive_or_expression>
519 logical_and_expression
520 inclusive_or_expression .and .loop logical_and_expression_1;
521 logical_and_expression_1
522 ampersandampersand .and inclusive_or_expression .and .true .emit OP_LOGICALAND;
525 * <logical_xor_expression> ::= <logical_and_expression>
526 * | <logical_xor_expression> "^^" <logical_and_expression>
528 logical_xor_expression
529 logical_and_expression .and .loop logical_xor_expression_1;
530 logical_xor_expression_1
531 caretcaret .and logical_and_expression .and .true .emit OP_LOGICALXOR;
534 * <logical_or_expression> ::= <logical_xor_expression>
535 * | <logical_or_expression> "||" <logical_xor_expression>
537 logical_or_expression
538 logical_xor_expression .and .loop logical_or_expression_1;
539 logical_or_expression_1
540 barbar .and logical_xor_expression .and .true .emit OP_LOGICALOR;
543 * <conditional_expression> ::= <logical_or_expression>
544 * | <logical_or_expression> "?" <expression> ":" <conditional_expression>
546 conditional_expression
547 logical_or_expression .and .loop conditional_expression_1;
548 conditional_expression_1
549 question .and expression .and colon .and conditional_expression .and .true .emit OP_SELECT;
552 * <assignment_expression> ::= <conditional_expression>
553 * | <unary_expression> <assignment_operator> <assignment_expression>
555 * <assignment_operator> ::= "="
561 * | "<<=" // reserved
562 * | ">>=" // reserved
567 assignment_expression
568 assignment_expression_1 .or assignment_expression_2 .or assignment_expression_3 .or
569 assignment_expression_4 .or assignment_expression_5/* .or assignment_expression_6 .or
570 assignment_expression_7 .or assignment_expression_8 .or assignment_expression_9 .or
571 assignment_expression_10 .or assignment_expression_11*/ .or conditional_expression;
572 assignment_expression_1
573 unary_expression .and equals .and assignment_expression .and .true .emit OP_ASSIGN;
574 assignment_expression_2
575 unary_expression .and starequals .and assignment_expression .and .true .emit OP_MULASSIGN;
576 assignment_expression_3
577 unary_expression .and slashequals .and assignment_expression .and .true .emit OP_DIVASSIGN;
578 assignment_expression_4
579 unary_expression .and plusequals .and assignment_expression .and .true .emit OP_ADDASSIGN;
580 assignment_expression_5
581 unary_expression .and minusequals .and assignment_expression .and .true .emit OP_SUBASSIGN;
582 /*assignment_expression_6
583 unary_expression .and percentequals .and assignment_expression .and .true .emit OP_MODASSIGN;*/
584 /*assignment_expression_7
585 unary_expression .and lesslessequals .and assignment_expression .and .true .emit OP_LSHASSIGN;*/
586 /*assignment_expression_8
587 unary_expression .and greatergreaterequals .and assignment_expression .and
588 .true .emit OP_RSHASSIGN;*/
589 /*assignment_expression_9
590 unary_expression .and ampersandequals .and assignment_expression .and .true .emit OP_ANDASSIGN;*/
591 /*assignment_expression_10
592 unary_expression .and caretequals .and assignment_expression .and .true .emit OP_XORASSIGN;*/
593 /*assignment_expression_11
594 unary_expression .and barequals .and assignment_expression .and .true .emit OP_ORASSIGN;*/
597 * <expression> ::= <assignment_expression>
598 * | <expression> "," <assignment_expression>
601 assignment_expression .and .loop expression_1;
603 comma .and assignment_expression .and .true .emit OP_SEQUENCE;
606 * <constant_expression> ::= <conditional_expression>
609 conditional_expression .and .true .emit OP_END;
612 * <declaration> ::= <function_prototype> ";"
613 * | <init_declarator_list> ";"
616 declaration_1 .or declaration_2;
618 function_prototype .emit DECLARATION_FUNCTION_PROTOTYPE .and semicolon;
620 init_declarator_list .emit DECLARATION_INIT_DECLARATOR_LIST .and semicolon;
623 * <function_prototype> ::= <function_header> "void" ")"
624 * | <function_declarator> ")"
627 function_prototype_1 .or function_prototype_2;
629 function_header .and "void" .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;
631 function_declarator .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;
634 * <function_declarator> ::= <function_header>
635 * | <function_header_with_parameters>
638 function_header_with_parameters .or function_header;
641 * <function_header_with_parameters> ::= <function_header> <parameter_declaration>
642 * | <function_header_with_parameters> ","
643 * <parameter_declaration>
645 function_header_with_parameters
646 function_header .and parameter_declaration .and .loop function_header_with_parameters_1;
647 function_header_with_parameters_1
648 comma .and parameter_declaration;
651 * <function_header> ::= <fully_specified_type> <identifier> "("
654 function_header_nospace .or function_header_space;
655 function_header_space
656 fully_specified_type_space .and space .and function_decl_identifier .and lparen;
657 function_header_nospace
658 fully_specified_type_nospace .and function_decl_identifier .and lparen;
661 * <function_decl_identifier> ::= "__constructor"
665 * note: this is an extension to the standard language specification.
666 * normally slang disallows operator and constructor prototypes and definitions
668 function_decl_identifier
669 .if (parsing_builtin != 0) __operator .emit FUNCTION_OPERATOR .or
670 .if (parsing_builtin != 0) "__constructor" .emit FUNCTION_CONSTRUCTOR .or
671 identifier .emit FUNCTION_ORDINARY;
674 * <__operator> ::= "__operator" <overriden_op>
676 * note: this is an extension to the standard language specification.
677 * normally slang disallows operator prototypes and definitions
680 "__operator" .and overriden_operator .error INVALID_OPERATOR_OVERRIDE;
683 * <overriden_op> ::= "="
689 * | "<<=" // reserved
690 * | ">>=" // reserved
716 * note: this is an extension to the standard language specification.
717 * normally slang disallows operator prototypes and definitions
720 plusplus .emit OPERATOR_INCREMENT .or
721 plusequals .emit OPERATOR_ADDASSIGN .or
722 plus .emit OPERATOR_PLUS .or
723 minusminus .emit OPERATOR_DECREMENT .or
724 minusequals .emit OPERATOR_SUBASSIGN .or
725 minus .emit OPERATOR_MINUS .or
726 bang .emit OPERATOR_NOT .or
727 starequals .emit OPERATOR_MULASSIGN .or
728 star .emit OPERATOR_MULTIPLY .or
729 slashequals .emit OPERATOR_DIVASSIGN .or
730 slash .emit OPERATOR_DIVIDE .or
731 lessequals .emit OPERATOR_LESSEQUAL .or
732 /*lesslessequals .emit OPERATOR_LSHASSIGN .or*/
733 /*lessless .emit OPERATOR_LSHIFT .or*/
734 less .emit OPERATOR_LESS .or
735 greaterequals .emit OPERATOR_GREATEREQUAL .or
736 /*greatergreaterequals .emit OPERATOR_RSHASSIGN .or*/
737 /*greatergreater .emit OPERATOR_RSHIFT .or*/
738 greater .emit OPERATOR_GREATER .or
739 /*percentequals .emit OPERATOR_MODASSIGN .or*/
740 /*percent .emit OPERATOR_MODULUS .or*/
741 /*ampersandequals .emit OPERATOR_ANDASSIGN */
742 /*ampersand .emit OPERATOR_BITAND .or*/
743 /*barequals .emit OPERATOR_ORASSIGN .or*/
744 /*bar .emit OPERATOR_BITOR .or*/
745 /*tilde .emit OPERATOR_COMPLEMENT .or*/
746 /*caretequals .emit OPERATOR_XORASSIGN .or*/
747 caretcaret .emit OPERATOR_LOGICALXOR /*.or
748 caret .emit OPERATOR_BITXOR*/;
751 * <parameter_declarator> ::= <type_specifier> <identifier>
752 * | <type_specifier> <identifier> "[" <constant_expression> "]"
755 parameter_declarator_nospace .or parameter_declarator_space;
756 parameter_declarator_nospace
757 type_specifier_nospace .and identifier .and parameter_declarator_1;
758 parameter_declarator_space
759 type_specifier_space .and space .and identifier .and parameter_declarator_1;
760 parameter_declarator_1
761 parameter_declarator_2 .emit PARAMETER_ARRAY_PRESENT .or
762 .true .emit PARAMETER_ARRAY_NOT_PRESENT;
763 parameter_declarator_2
764 lbracket .and constant_expression .and rbracket;
767 * <parameter_declaration> ::= <type_qualifier> <parameter_qualifier>
768 * <precision> <parameter_declarator>
769 * | <type_qualifier> <parameter_qualifier>
770 * <precision> <parameter_type_specifier>
771 * | <type_qualifier> <parameter_qualifier>
772 * <parameter_declarator>
773 * | <type_qualifier> <parameter_qualifier>
774 * <parameter_type_specifier>
775 * | <parameter_qualifier> <precision>
776 * <parameter_declarator>
777 * | <parameter_qualifier> <precision>
778 * <parameter_type_specifier>
779 * | <parameter_qualifier> <parameter_declarator>
780 * | <parameter_qualifier> <parameter_type_specifier>
782 parameter_declaration
783 parameter_declaration_1 .emit PARAMETER_NEXT;
784 parameter_declaration_1
785 parameter_declaration_2 .or parameter_declaration_3;
786 parameter_declaration_2
787 type_qualifier .and space .and parameter_qualifier .and parameter_declaration_4;
788 parameter_declaration_3
789 parameter_qualifier .emit TYPE_QUALIFIER_NONE .and parameter_declaration_4;
790 parameter_declaration_4
791 parameter_declaration_optprec .and parameter_declaration_rest;
792 parameter_declaration_optprec
793 parameter_declaration_prec .or .true .emit PRECISION_DEFAULT;
794 parameter_declaration_prec
795 precision .and space;
796 parameter_declaration_rest
797 parameter_declarator .or parameter_type_specifier;
800 * <parameter_qualifier> ::= "in"
806 parameter_qualifier_1 .or .true .emit PARAM_QUALIFIER_IN;
807 parameter_qualifier_1
808 parameter_qualifier_2 .and space;
809 parameter_qualifier_2
810 "in" .emit PARAM_QUALIFIER_IN .or
811 "out" .emit PARAM_QUALIFIER_OUT .or
812 "inout" .emit PARAM_QUALIFIER_INOUT;
815 * <parameter_type_specifier> ::= <type_specifier>
816 * | <type_specifier> "[" <constant_expression> "]"
818 parameter_type_specifier
819 parameter_type_specifier_1 .and .true .emit '\0' .and parameter_type_specifier_2;
820 parameter_type_specifier_1
821 type_specifier_nospace .or type_specifier_space;
822 parameter_type_specifier_2
823 parameter_type_specifier_3 .emit PARAMETER_ARRAY_PRESENT .or
824 .true .emit PARAMETER_ARRAY_NOT_PRESENT;
825 parameter_type_specifier_3
826 lbracket .and constant_expression .and rbracket;
829 * <init_declarator_list> ::= <single_declaration>
830 * | <init_declarator_list> "," <identifier>
831 * | <init_declarator_list> "," <identifier> "[" "]"
832 * | <init_declarator_list> "," <identifier> "["
833 * <constant_expression> "]"
834 * | <init_declarator_list> "," <identifier> "="
838 single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and
839 .true .emit DECLARATOR_NONE;
840 init_declarator_list_1
841 comma .and identifier .emit VARIABLE_IDENTIFIER .and init_declarator_list_2;
842 init_declarator_list_2
843 init_declarator_list_3 .or init_declarator_list_4 .or .true .emit VARIABLE_NONE;
844 init_declarator_list_3
845 equals .and initializer .emit VARIABLE_INITIALIZER;
846 init_declarator_list_4
847 lbracket .and init_declarator_list_5 .and rbracket;
848 init_declarator_list_5
849 constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
852 * <single_declaration> ::= <fully_specified_type>
853 * | <fully_specified_type> <identifier>
854 * | <fully_specified_type> <identifier> "[" "]"
855 * | <fully_specified_type> <identifier> "["
856 * <constant_expression> "]"
857 * | <fully_specified_type> <identifier> "=" <initializer>
860 single_declaration_nospace .or single_declaration_space;
861 single_declaration_space
862 fully_specified_type_space .and single_declaration_space_1;
863 single_declaration_nospace
864 fully_specified_type_nospace .and single_declaration_nospace_1;
865 single_declaration_space_1
866 single_declaration_space_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
867 single_declaration_nospace_1
868 single_declaration_nospace_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
869 single_declaration_space_2
870 space .and identifier .and single_declaration_3;
871 single_declaration_nospace_2
872 identifier .and single_declaration_3;
874 single_declaration_4 .or single_declaration_5 .or .true .emit VARIABLE_NONE;
876 equals .and initializer .emit VARIABLE_INITIALIZER;
878 lbracket .and single_declaration_6 .and rbracket;
880 constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
883 * <fully_specified_type> ::= <type_specifier>
884 * | <type_qualifier> <type_specifier>
885 * | <precision> <type_specifier>
886 * | <type_qualifier> <precision> <type_specifier>
888 fully_specified_type_space
889 fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_space;
890 fully_specified_type_nospace
891 fully_specified_type_optqual .and fully_specified_type_optprec .and type_specifier_nospace;
892 fully_specified_type_optqual
893 fully_specified_type_qual .or .true .emit TYPE_QUALIFIER_NONE;
894 fully_specified_type_qual
895 type_qualifier .and space;
896 fully_specified_type_optprec
897 fully_specified_type_prec .or .true .emit PRECISION_DEFAULT;
898 fully_specified_type_prec
899 precision .and space;
902 * <type_qualifier> ::= "const"
903 * | "attribute" // Vertex only.
909 * note: this is an extension to the standard language specification,
910 * normally slang disallows __fixed_output and __fixed_input type qualifiers
913 "const" .emit TYPE_QUALIFIER_CONST .or
914 .if (shader_type == 2) "attribute" .emit TYPE_QUALIFIER_ATTRIBUTE .or
915 "varying" .emit TYPE_QUALIFIER_VARYING .or
916 "uniform" .emit TYPE_QUALIFIER_UNIFORM .or
917 .if (parsing_builtin != 0) "__fixed_output" .emit TYPE_QUALIFIER_FIXEDOUTPUT .or
918 .if (parsing_builtin != 0) "__fixed_input" .emit TYPE_QUALIFIER_FIXEDINPUT;
921 * <type_specifier> ::= "void"
947 * | "sampler1DShadow"
948 * | "sampler2DShadow"
950 * | "sampler2DRectShadow"
951 * | <struct_specifier>
955 "void" .emit TYPE_SPECIFIER_VOID .or
956 "float" .emit TYPE_SPECIFIER_FLOAT .or
957 "int" .emit TYPE_SPECIFIER_INT .or
958 "bool" .emit TYPE_SPECIFIER_BOOL .or
959 "vec2" .emit TYPE_SPECIFIER_VEC2 .or
960 "vec3" .emit TYPE_SPECIFIER_VEC3 .or
961 "vec4" .emit TYPE_SPECIFIER_VEC4 .or
962 "bvec2" .emit TYPE_SPECIFIER_BVEC2 .or
963 "bvec3" .emit TYPE_SPECIFIER_BVEC3 .or
964 "bvec4" .emit TYPE_SPECIFIER_BVEC4 .or
965 "ivec2" .emit TYPE_SPECIFIER_IVEC2 .or
966 "ivec3" .emit TYPE_SPECIFIER_IVEC3 .or
967 "ivec4" .emit TYPE_SPECIFIER_IVEC4 .or
968 "mat2" .emit TYPE_SPECIFIER_MAT2 .or
969 "mat3" .emit TYPE_SPECIFIER_MAT3 .or
970 "mat4" .emit TYPE_SPECIFIER_MAT4 .or
971 "mat2x3" .emit TYPE_SPECIFIER_MAT23 .or
972 "mat3x2" .emit TYPE_SPECIFIER_MAT32 .or
973 "mat2x4" .emit TYPE_SPECIFIER_MAT24 .or
974 "mat4x2" .emit TYPE_SPECIFIER_MAT42 .or
975 "mat3x4" .emit TYPE_SPECIFIER_MAT34 .or
976 "mat4x3" .emit TYPE_SPECIFIER_MAT43 .or
977 "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
978 "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
979 "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
980 "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
981 "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
982 "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
983 "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
984 "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW .or
985 type_name .emit TYPE_SPECIFIER_TYPENAME;
986 type_specifier_nospace
987 struct_specifier .emit TYPE_SPECIFIER_STRUCT;
990 * <struct_specifier> ::= "struct" <identifier> "{" <struct_declaration_list> "}"
991 * | "struct" "{" <struct_declaration_list> "}"
994 "struct" .and struct_specifier_1 .and optional_space .and lbrace .error LBRACE_EXPECTED .and
995 struct_declaration_list .and rbrace .emit FIELD_NONE;
997 struct_specifier_2 .or .true .emit '\0';
999 space .and identifier;
1002 * <struct_declaration_list> ::= <struct_declaration>
1003 * | <struct_declaration_list> <struct_declaration>
1005 struct_declaration_list
1006 struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;
1009 * <struct_declaration> ::= <type_specifier> <struct_declarator_list> ";"
1012 struct_declaration_nospace .or struct_declaration_space;
1013 struct_declaration_space
1014 type_specifier_space .and space .and struct_declarator_list .and semicolon .emit FIELD_NONE;
1015 struct_declaration_nospace
1016 type_specifier_nospace .and struct_declarator_list .and semicolon .emit FIELD_NONE;
1019 * <struct_declarator_list> ::= <struct_declarator>
1020 * | <struct_declarator_list> "," <struct_declarator>
1022 struct_declarator_list
1023 struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT;
1024 struct_declarator_list_1
1025 comma .and struct_declarator;
1028 * <struct_declarator> ::= <identifier>
1029 * | <identifier> "[" <constant_expression> "]"
1032 identifier .and struct_declarator_1;
1034 struct_declarator_2 .emit FIELD_ARRAY .or .true .emit FIELD_NONE;
1036 lbracket .and constant_expression .and rbracket;
1039 * <initializer> ::= <assignment_expression>
1042 assignment_expression .and .true .emit OP_END;
1045 * <declaration_statement> ::= <declaration>
1047 declaration_statement
1051 * <statement> ::= <compound_statement>
1052 * | <simple_statement>
1055 compound_statement .or simple_statement;
1057 compound_statement .or statement_space_1;
1059 space .and simple_statement;
1062 * <simple_statement> ::= <__asm_statement>
1063 * | <selection_statement>
1064 * | <iteration_statement>
1065 * | <jump_statement>
1066 * | <expression_statement>
1067 * | <declaration_statement>
1069 * note: this is an extension to the standard language specification.
1070 * normally slang disallows use of __asm statements
1073 .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or
1074 selection_statement .or
1075 iteration_statement .or
1076 precision_stmt .emit OP_PRECISION .or
1078 expression_statement .emit OP_EXPRESSION .or
1079 declaration_statement .emit OP_DECLARE;
1082 * <compound_statement> ::= "{" "}"
1083 * | "{" <statement_list> "}"
1086 compound_statement_1 .emit OP_BLOCK_BEGIN_NEW_SCOPE .and .true .emit OP_END;
1087 compound_statement_1
1088 compound_statement_2 .or compound_statement_3;
1089 compound_statement_2
1091 compound_statement_3
1092 lbrace .and statement_list .and rbrace;
1095 * <statement_no_new_scope> ::= <compound_statement_no_new_scope>
1096 * | <simple_statement>
1098 statement_no_new_scope
1099 compound_statement_no_new_scope .or simple_statement;
1102 * <compound_statement_no_new_scope> ::= "{" "}"
1103 * | "{" <statement_list> "}"
1105 compound_statement_no_new_scope
1106 compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;
1107 compound_statement_no_new_scope_1
1108 compound_statement_no_new_scope_2 .or compound_statement_no_new_scope_3;
1109 compound_statement_no_new_scope_2
1111 compound_statement_no_new_scope_3
1112 lbrace .and statement_list .and rbrace;
1115 * <statement_list> ::= <statement>
1116 * | <statement_list> <statement>
1119 statement .and .loop statement;
1122 * <expression_statement> ::= ";"
1123 * | <expression> ";"
1125 expression_statement
1126 expression_statement_1 .or expression_statement_2;
1127 expression_statement_1
1128 semicolon .emit OP_PUSH_VOID .emit OP_END;
1129 expression_statement_2
1130 expression .and semicolon .emit OP_END;
1133 * <selection_statement> ::= "if" "(" <expression> ")" <selection_rest_statement>
1136 "if" .emit OP_IF .and lparen .error LPAREN_EXPECTED .and expression .and
1137 rparen .error RPAREN_EXPECTED .emit OP_END .and selection_rest_statement;
1140 * <selection_rest_statement> ::= <statement> "else" <statement>
1143 selection_rest_statement
1144 statement .and selection_rest_statement_1;
1145 selection_rest_statement_1
1146 selection_rest_statement_2 .or .true .emit OP_EXPRESSION .emit OP_PUSH_VOID .emit OP_END;
1147 selection_rest_statement_2
1148 "else" .and optional_space .and statement;
1151 * <condition> ::= <expression>
1152 * | <fully_specified_type> <identifier> "=" <initializer>
1154 * note: if <condition_1> is executed, the emit format must
1155 * match <declaration> emit format
1158 condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or
1159 condition_3 .emit OP_EXPRESSION;
1161 condition_1_nospace .or condition_1_space;
1163 fully_specified_type_nospace .and condition_2;
1165 fully_specified_type_space .and space .and condition_2;
1167 identifier .emit VARIABLE_IDENTIFIER .and equals .emit VARIABLE_INITIALIZER .and
1168 initializer .and .true .emit DECLARATOR_NONE;
1170 expression .and .true .emit OP_END;
1173 * <iteration_statement> ::= "while" "(" <condition> ")" <statement>
1174 * | "do" <statement> "while" "(" <expression> ")" ";"
1175 * | "for" "(" <for_init_statement> <for_rest_statement> ")"
1176 * <statement_no_new_scope>
1179 iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;
1180 iteration_statement_1
1181 "while" .emit OP_WHILE .and lparen .error LPAREN_EXPECTED .and condition .and
1182 rparen .error RPAREN_EXPECTED .and statement;
1183 iteration_statement_2
1184 "do" .emit OP_DO .and statement_space .and "while" .and lparen .error LPAREN_EXPECTED .and
1185 expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;
1186 iteration_statement_3
1187 "for" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and
1188 for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement_no_new_scope;
1191 * <for_init_statement> ::= <expression_statement>
1192 * | <declaration_statement>
1195 expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;
1198 * <conditionopt> ::= <condition>
1201 * note: <conditionopt> is used only by "for" statement.
1202 * if <condition> is ommitted, parser simulates default behaviour,
1203 * that is simulates "true" expression
1207 .true .emit OP_EXPRESSION .emit OP_PUSH_BOOL .emit 2 .emit '1' .emit '\0' .emit OP_END;
1210 * <for_rest_statement> ::= <conditionopt> ";"
1211 * | <conditionopt> ";" <expression>
1214 conditionopt .and semicolon .and for_rest_statement_1;
1215 for_rest_statement_1
1216 for_rest_statement_2 .or .true .emit OP_PUSH_VOID .emit OP_END;
1217 for_rest_statement_2
1218 expression .and .true .emit OP_END;
1221 * <jump_statement> ::= "continue" ";"
1224 * | "return" <expression> ";"
1225 * | "discard" ";" // Fragment shader only.
1228 jump_statement_1 .or jump_statement_2 .or jump_statement_3 .or jump_statement_4 .or
1229 .if (shader_type == 1) jump_statement_5;
1231 "continue" .and semicolon .emit OP_CONTINUE;
1233 "break" .and semicolon .emit OP_BREAK;
1235 "return" .emit OP_RETURN .and optional_space .and expression .and semicolon .emit OP_END;
1237 "return" .emit OP_RETURN .and semicolon .emit OP_PUSH_VOID .emit OP_END;
1239 "discard" .and semicolon .emit OP_DISCARD;
1242 * <__asm_statement> ::= "__asm" <identifier> <asm_arguments> ";"
1244 * note: this is an extension to the standard language specification.
1245 * normally slang disallows __asm statements
1248 "__asm" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;
1251 * <asm_arguments> ::= <asm_argument>
1252 * | <asm_arguments> "," <asm_argument>
1254 * note: this is an extension to the standard language specification.
1255 * normally slang disallows __asm statements
1258 asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;
1260 comma .and asm_argument .and .true .emit OP_END;
1263 * <asm_argument> ::= <variable_identifier>
1266 * note: this is an extension to the standard language specification.
1267 * normally slang disallows __asm statements
1271 variable_identifier .or
1275 variable_identifier .and dot .and field_selection .emit OP_FIELD;
1279 * <translation_unit> ::= <external_declaration>
1280 * | <translation_unit> <external_declaration>
1283 optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and
1284 .loop external_declaration .and optional_space .and
1285 '\0' .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;
1289 * <external_declaration> ::= <function_definition>
1292 external_declaration
1293 precision_stmt .emit DEFAULT_PRECISION .or
1294 invariant_stmt .emit INVARIANT_STMT .or
1295 function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or
1296 declaration .emit EXTERNAL_DECLARATION;
1300 * <precision_stmt> ::= "precision" <precision> <prectype>
1303 "precision" .and space .and precision .error INVALID_PRECISION .and space .and prectype .error INVALID_PRECISION_TYPE .and semicolon;
1306 * <precision> ::= "lowp"
1311 "lowp" .emit PRECISION_LOW .or
1312 "mediump" .emit PRECISION_MEDIUM .or
1313 "highp" .emit PRECISION_HIGH;
1316 * <prectype> ::= "int"
1318 * | "a sampler type"
1321 "int" .emit TYPE_SPECIFIER_INT .or
1322 "float" .emit TYPE_SPECIFIER_FLOAT .or
1323 "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
1324 "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
1325 "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
1326 "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
1327 "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
1328 "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
1329 "sampler2DRect" .emit TYPE_SPECIFIER_SAMPLER2DRECT .or
1330 "sampler2DRectShadow" .emit TYPE_SPECIFIER_SAMPLER2DRECTSHADOW;
1334 * <invariant_stmt> ::= "invariant" identifier;
1337 "invariant" .and space .and identifier .and semicolon;
1341 * <function_definition> :: <function_prototype> <compound_statement_no_new_scope>
1344 function_prototype .and compound_statement_no_new_scope;
1349 * helper rules, not part of the official language syntax
1359 '0'-'9' .or 'A'-'F' .or 'a'-'f';
1362 'a'-'z' .or 'A'-'Z' .or '_';
1365 id_character_first .or digit_dec;
1368 id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\0';
1371 float_1 .or float_2;
1373 float_fractional_constant .and float_optional_exponent_part;
1375 float_digit_sequence .and .true .emit '\0' .and float_exponent_part;
1377 float_fractional_constant
1378 float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;
1379 float_fractional_constant_1
1380 float_digit_sequence .and '.' .and float_digit_sequence;
1381 float_fractional_constant_2
1382 float_digit_sequence .and '.' .and .true .emit '\0';
1383 float_fractional_constant_3
1384 '.' .emit '\0' .and float_digit_sequence;
1386 float_optional_exponent_part
1387 float_exponent_part .or .true .emit '\0';
1389 float_digit_sequence
1390 digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
1393 float_exponent_part_1 .or float_exponent_part_2;
1394 float_exponent_part_1
1395 'e' .and float_optional_sign .and float_digit_sequence;
1396 float_exponent_part_2
1397 'E' .and float_optional_sign .and float_digit_sequence;
1400 float_sign .or .true;
1403 '+' .or '-' .emit '-';
1406 integer_hex .or integer_oct .or integer_dec;
1409 '0' .and integer_hex_1 .emit 0x10 .and digit_hex .emit * .and .loop digit_hex .emit * .and
1415 '0' .emit 8 .emit * .and .loop digit_oct .emit * .and .true .emit '\0';
1418 digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
1421 "true" .emit 2 .emit '1' .emit '\0' .or
1422 "false" .emit 2 .emit '0' .emit '\0';
1431 float .emit OP_PUSH_FLOAT;
1434 integer .emit OP_PUSH_INT;
1437 boolean .emit OP_PUSH_BOOL;
1443 single_space .and .loop single_space;
1446 white_char .or c_style_comment_block .or cpp_style_comment_block;
1449 ' ' .or '\t' .or new_line .or '\v' .or '\f';
1452 cr_lf .or lf_cr .or '\n' .or '\r';
1460 c_style_comment_block
1461 '/' .and '*' .and c_style_comment_rest;
1463 c_style_comment_rest
1464 .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
1465 c_style_comment_rest_1
1466 c_style_comment_end .or c_style_comment_rest_2;
1467 c_style_comment_rest_2
1468 '*' .and c_style_comment_rest;
1470 c_style_comment_char_no_star
1471 '\x2B'-'\xFF' .or '\x01'-'\x29';
1476 cpp_style_comment_block
1477 '/' .and '/' .and cpp_style_comment_block_1;
1478 cpp_style_comment_block_1
1479 cpp_style_comment_block_2 .or cpp_style_comment_block_3;
1480 cpp_style_comment_block_2
1481 .loop cpp_style_comment_char .and new_line;
1482 cpp_style_comment_block_3
1483 .loop cpp_style_comment_char;
1485 cpp_style_comment_char
1486 '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
1491 optional_space .and '&' .and optional_space;*/
1494 optional_space .and '&' .and '&' .and optional_space;
1497 optional_space .and '&' .and '=' .and optional_space;*/
1500 optional_space .and '|' .and optional_space;*/
1503 optional_space .and '|' .and '|' .and optional_space;
1506 optional_space .and '|' .and '=' .and optional_space;*/
1509 optional_space .and '!' .and optional_space;
1512 optional_space .and '!' .and '=' .and optional_space;
1515 optional_space .and '^' .and optional_space;*/
1518 optional_space .and '^' .and '^' .and optional_space;
1521 optional_space .and '^' .and '=' .and optional_space;*/
1524 optional_space .and ':' .and optional_space;
1527 optional_space .and ',' .and optional_space;
1530 optional_space .and '.' .and optional_space;
1533 optional_space .and '=' .and optional_space;
1536 optional_space .and '=' .and '=' .and optional_space;
1539 optional_space .and '>' .and optional_space;
1542 optional_space .and '>' .and '=' .and optional_space;
1545 optional_space .and '>' .and '>' .and optional_space;*/
1547 /*greatergreaterequals
1548 optional_space .and '>' .and '>' .and '=' .and optional_space;*/
1551 optional_space .and '{' .and optional_space;
1554 optional_space .and '[' .and optional_space;
1557 optional_space .and '<' .and optional_space;
1560 optional_space .and '<' .and '=' .and optional_space;
1563 optional_space .and '<' .and '<' .and optional_space;*/
1566 optional_space .and '<' .and '<' .and '=' .and optional_space;*/
1569 optional_space .and '(' .and optional_space;
1572 optional_space .and '-' .and optional_space;
1575 optional_space .and '-' .and '=' .and optional_space;
1578 optional_space .and '-' .and '-' .and optional_space;
1581 optional_space .and '%' .and optional_space;*/
1584 optional_space .and '%' .and '=' .and optional_space;*/
1587 optional_space .and '+' .and optional_space;
1590 optional_space .and '+' .and '=' .and optional_space;
1593 optional_space .and '+' .and '+' .and optional_space;
1596 optional_space .and '?' .and optional_space;
1599 optional_space .and '}' .and optional_space;
1602 optional_space .and ']' .and optional_space;
1605 optional_space .and ')' .and optional_space;
1608 optional_space .and ';' .and optional_space;
1611 optional_space .and '/' .and optional_space;
1614 optional_space .and '/' .and '=' .and optional_space;
1617 optional_space .and '*' .and optional_space;
1620 optional_space .and '*' .and '=' .and optional_space;
1623 optional_space .and '~' .and optional_space;*/
1625 /* string rules - these are used internally by the parser when parsing quoted strings */
1627 .string string_lexer;
1630 lex_first_identifier_character .and .loop lex_next_identifier_character;
1632 lex_first_identifier_character
1633 'a'-'z' .or 'A'-'Z' .or '_';
1635 lex_next_identifier_character
1636 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
1638 /* error rules - these are used by error messages */
1641 '~' .or '`' .or '!' .or '@' .or '#' .or '$' .or '%' .or '^' .or '&' .or '*' .or '(' .or ')' .or
1642 '-' .or '+' .or '=' .or '|' .or '\\' .or '[' .or ']' .or '{' .or '}' .or ':' .or ';' .or '"' .or
1643 '\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;
1646 id_character_first .and .loop id_character_next;