2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 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.
27 * syntax parsing engine language syntax
32 ".emtcode DECLARATION_END 0x00\n"
33 ".emtcode DECLARATION_EMITCODE 0x01\n"
34 ".emtcode DECLARATION_ERRORTEXT 0x02\n"
35 ".emtcode DECLARATION_REGBYTE 0x03\n"
36 ".emtcode DECLARATION_LEXER 0x04\n"
37 ".emtcode DECLARATION_RULE 0x05\n"
38 ".emtcode SPECIFIER_END 0x00\n"
39 ".emtcode SPECIFIER_AND_TAG 0x01\n"
40 ".emtcode SPECIFIER_OR_TAG 0x02\n"
41 ".emtcode SPECIFIER_CHARACTER_RANGE 0x03\n"
42 ".emtcode SPECIFIER_CHARACTER 0x04\n"
43 ".emtcode SPECIFIER_STRING 0x05\n"
44 ".emtcode SPECIFIER_IDENTIFIER 0x06\n"
45 ".emtcode SPECIFIER_TRUE 0x07\n"
46 ".emtcode SPECIFIER_FALSE 0x08\n"
47 ".emtcode SPECIFIER_DEBUG 0x09\n"
48 ".emtcode IDENTIFIER_NO_LOOP 0x00\n"
49 ".emtcode IDENTIFIER_LOOP 0x01\n"
50 ".emtcode ERROR_NOT_PRESENT 0x00\n"
51 ".emtcode ERROR_PRESENT 0x01\n"
52 ".emtcode EMIT_NULL 0x00\n"
53 ".emtcode EMIT_INTEGER 0x01\n"
54 ".emtcode EMIT_IDENTIFIER 0x02\n"
55 ".emtcode EMIT_CHARACTER 0x03\n"
56 ".emtcode EMIT_LAST_CHARACTER 0x04\n"
57 ".emtcode EMIT_CURRENT_POSITION 0x05\n"
58 ".errtext INVALID_GRAMMAR \"internal error 2001: invalid grammar script\"\n"
59 ".errtext SYNTAX_EXPECTED \"internal error 2002: '.syntax' keyword expected\"\n"
60 ".errtext IDENTIFIER_EXPECTED \"internal error 2003: identifier expected\"\n"
61 ".errtext MISSING_SEMICOLON \"internal error 2004: missing ';'\"\n"
62 ".errtext INTEGER_EXPECTED \"internal error 2005: integer value expected\"\n"
63 ".errtext STRING_EXPECTED \"internal error 2006: string expected\"\n"
65 " grammar_1 .error INVALID_GRAMMAR;\n"
67 " optional_space .and \".syntax\" .error SYNTAX_EXPECTED .and space .and identifier .and\n"
68 " semicolon .and declaration_list .and optional_space .and '\\0' .emit DECLARATION_END;\n"
72 " single_space .and .loop single_space;\n"
74 " white_char .or comment_block;\n"
76 " ' ' .or '\\t' .or '\\n' .or '\\r';\n"
78 " '/' .and '*' .and .loop comment_char .and '*' .and '/';\n"
80 " comment_char_no_star .or comment_char_1;\n"
82 " '*' .and comment_char_no_slash;\n"
83 "comment_char_no_star\n"
84 " '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
85 "comment_char_no_slash\n"
86 " '\\x30'-'\\xFF' .or '\\x01'-'\\x2E';\n"
88 " identifier_ne .error IDENTIFIER_EXPECTED;\n"
90 " first_idchar .emit * .and .loop follow_idchar .emit * .and .true .emit '\\0';\n"
92 " 'a'-'z' .or 'A'-'Z' .or '_';\n"
94 " first_idchar .or digit_dec;\n"
98 " optional_space .and ';' .error MISSING_SEMICOLON .and optional_space;\n"
100 " declaration .and .loop declaration;\n"
102 " emitcode_definition .emit DECLARATION_EMITCODE .or\n"
103 " errortext_definition .emit DECLARATION_ERRORTEXT .or\n"
104 " regbyte_definition .emit DECLARATION_REGBYTE .or\n"
105 " lexer_definition .emit DECLARATION_LEXER .or\n"
106 " rule_definition .emit DECLARATION_RULE;\n"
107 "emitcode_definition\n"
108 " \".emtcode\" .and space .and identifier .and space .and integer .and space_or_null;\n"
110 " integer_ne .error INTEGER_EXPECTED;\n"
112 " hex_prefix .and digit_hex .emit * .and .loop digit_hex .emit * .and .true .emit '\\0';\n"
114 " '0' .and hex_prefix_1;\n"
118 " '0'-'9' .or 'a'-'f' .or 'A'-'F';\n"
120 " space .or '\\0';\n"
121 "errortext_definition\n"
122 " \".errtext\" .and space .and identifier .and space .and string .and space_or_null;\n"
124 " string_ne .error STRING_EXPECTED;\n"
126 " '\"' .and .loop string_char_double_quotes .and '\"' .emit '\\0';\n"
127 "string_char_double_quotes\n"
128 " escape_sequence .or string_char .emit * .or '\\'' .emit *;\n"
130 " '\\x5D'-'\\xFF' .or '\\x28'-'\\x5B' .or '\\x23'-'\\x26' .or '\\x0E'-'\\x21' .or '\\x0B'-'\\x0C' .or\n"
131 " '\\x01'-'\\x09';\n"
133 " '\\\\' .emit * .and escape_code;\n"
135 " simple_escape_code .emit * .or hex_escape_code .or oct_escape_code;\n"
136 "simple_escape_code\n"
137 " '\\'' .or '\"' .or '?' .or '\\\\' .or 'a' .or 'b' .or 'f' .or 'n' .or 'r' .or 't' .or 'v';\n"
139 " 'x' .emit * .and digit_hex .emit * .and .loop digit_hex .emit *;\n"
141 " digit_oct .emit * .and optional_digit_oct .and optional_digit_oct;\n"
144 "optional_digit_oct\n"
145 " digit_oct .emit * .or .true;\n"
146 "regbyte_definition\n"
147 " \".regbyte\" .and space .and identifier .and space .and integer .and space_or_null;\n"
149 " \".string\" .and space .and identifier .and semicolon;\n"
151 " identifier_ne .and space .and definition;\n"
153 " specifier .and optional_specifiers_and_or .and semicolon .emit SPECIFIER_END;\n"
154 "optional_specifiers_and_or\n"
155 " and_specifiers .emit SPECIFIER_AND_TAG .or or_specifiers .emit SPECIFIER_OR_TAG .or .true;\n"
157 " specifier_condition .and optional_space .and specifier_rule;\n"
158 "specifier_condition\n"
159 " specifier_condition_1 .or .true;\n"
160 "specifier_condition_1\n"
161 " \".if\" .and optional_space .and '(' .and optional_space .and left_operand .and operator .and\n"
162 " right_operand .and optional_space .and ')';\n"
166 " operator_1 .or operator_2;\n"
168 " optional_space .and '!' .and '=' .and optional_space;\n"
170 " optional_space .and '=' .and '=' .and optional_space;\n"
174 " specifier_rule_1 .and optional_error .and .loop emit .and .true .emit EMIT_NULL;\n"
176 " character_range .emit SPECIFIER_CHARACTER_RANGE .or\n"
177 " character .emit SPECIFIER_CHARACTER .or\n"
178 " string_ne .emit SPECIFIER_STRING .or\n"
179 " \".true\" .emit SPECIFIER_TRUE .or\n"
180 " \".false\" .emit SPECIFIER_FALSE .or\n"
181 " \".debug\" .emit SPECIFIER_DEBUG .or\n"
182 " loop_identifier .emit SPECIFIER_IDENTIFIER;\n"
184 " '\\'' .and string_char_single_quotes .and '\\'' .emit '\\0';\n"
185 "string_char_single_quotes\n"
186 " escape_sequence .or string_char .emit * .or '\"' .emit *;\n"
188 " character .and optional_space .and '-' .and optional_space .and character;\n"
190 " optional_loop .and identifier;\n"
192 " optional_loop_1 .emit IDENTIFIER_LOOP .or .true .emit IDENTIFIER_NO_LOOP;\n"
194 " \".loop\" .and space;\n"
196 " error .emit ERROR_PRESENT .or .true .emit ERROR_NOT_PRESENT;\n"
198 " space .and \".error\" .and space .and identifier;\n"
200 " emit_output .or emit_regbyte;\n"
202 " space .and \".emit\" .and space .and emit_param;\n"
204 " integer_ne .emit EMIT_INTEGER .or\n"
205 " identifier_ne .emit EMIT_IDENTIFIER .or\n"
206 " character .emit EMIT_CHARACTER .or\n"
207 " '*' .emit EMIT_LAST_CHARACTER .or\n"
208 " '$' .emit EMIT_CURRENT_POSITION;\n"
210 " space .and \".load\" .and space .and identifier .and space .and emit_param;\n"
212 " and_specifier .and .loop and_specifier;\n"
214 " or_specifier .and .loop or_specifier;\n"
216 " space .and \".and\" .and space .and specifier;\n"
218 " space .and \".or\" .and space .and specifier;\n"
219 ".string __string_filter;\n"
221 " __first_identifier_char .and .loop __next_identifier_char;\n"
222 "__first_identifier_char\n"
223 " 'a'-'z' .or 'A'-'Z' .or '_' .or '.';\n"
224 "__next_identifier_char\n"
225 " 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';\n"