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 of .syn script - used to validate other syntax files
34 .emtcode DECLARATION_END 0
35 .emtcode DECLARATION_EMITCODE 1
36 .emtcode DECLARATION_ERRORTEXT 2
37 .emtcode DECLARATION_REGBYTE 3
38 .emtcode DECLARATION_LEXER 4
39 .emtcode DECLARATION_RULE 5
42 .emtcode SPECIFIER_END 0
43 .emtcode SPECIFIER_AND_TAG 1
44 .emtcode SPECIFIER_OR_TAG 2
45 .emtcode SPECIFIER_CHARACTER_RANGE 3
46 .emtcode SPECIFIER_CHARACTER 4
47 .emtcode SPECIFIER_STRING 5
48 .emtcode SPECIFIER_IDENTIFIER 6
49 .emtcode SPECIFIER_TRUE 7
50 .emtcode SPECIFIER_FALSE 8
51 .emtcode SPECIFIER_DEBUG 9
54 .emtcode IDENTIFIER_SIMPLE 0
55 .emtcode IDENTIFIER_LOOP 1
58 .emtcode ERROR_NOT_PRESENT 0
59 .emtcode ERROR_PRESENT 1
63 .emtcode EMIT_INTEGER 1
64 .emtcode EMIT_IDENTIFIER 2
65 .emtcode EMIT_CHARACTER 3
66 .emtcode EMIT_LAST_CHARACTER 4
67 .emtcode EMIT_CURRENT_POSITION 5
69 .errtext INVALID_GRAMMAR "internal error 2001: invalid grammar script"
70 .errtext SYNTAX_EXPECTED "internal error 2002: '.syntax' keyword expected"
71 .errtext IDENTIFIER_EXPECTED "internal error 2003: identifier expected"
72 .errtext MISSING_SEMICOLON "internal error 2004: missing ';'"
73 .errtext INTEGER_EXPECTED "internal error 2005: integer value expected"
74 .errtext STRING_EXPECTED "internal error 2006: string expected"
77 <grammar> ::= ".syntax" <identifier> ";" <declaration_list>
80 grammar_1 .error INVALID_GRAMMAR;
82 optional_space .and ".syntax" .error SYNTAX_EXPECTED .and space .and identifier .and
83 semicolon .and declaration_list .and optional_space .and '\0' .emit DECLARATION_END;
86 <optional_space> ::= <space>
93 <space> ::= <single_space> <single_space>*
96 single_space .and .loop single_space;
99 <single_space> ::= <white_char>
103 white_char .or comment_block;
112 ' ' .or '\t' .or '\n' .or '\r';
115 <comment_block> ::= "/" "*" <comment_rest>
118 '/' .and '*' .and comment_rest;
121 <comment_rest> ::= <comment_char_no_star>* <comment_end>
122 | <comment_char_no_star>* "*" <comment_rest>
125 .loop comment_char_no_star .and comment_rest_1;
127 comment_end .or comment_rest_2;
129 '*' .and comment_rest;
132 <comment_char_no_star> ::= All ASCII characters except "*" and "\0"
135 '\x2B'-'\xFF' .or '\x01'-'\x29';
138 <comment_end> ::= "*" "/"
144 <identifier> ::= <identifier>
147 identifier_ne .error IDENTIFIER_EXPECTED;
150 <identifier_ne> ::= <first_idchar> <follow_idchar>*
153 first_idchar .emit * .and .loop follow_idchar .emit * .and .true .emit '\0';
156 <first_idchar> ::= "a"-"z"
161 'a'-'z' .or 'A'-'Z' .or '_';
164 <follow_idchar> ::= <first_idchar>
168 first_idchar .or digit_dec;
171 <digit_dec> ::= "0"-"9"
180 optional_space .and ';' .error MISSING_SEMICOLON .and optional_space;
183 <declaration_list> ::= <declaration>
184 | <declaration_list> <declaration>
187 declaration .and .loop declaration;
190 <declaration> ::= <emitcode_definition>
191 | <errortext_definition>
196 emitcode_definition .emit DECLARATION_EMITCODE .or
197 errortext_definition .emit DECLARATION_ERRORTEXT .or
198 regbyte_definition .emit DECLARATION_REGBYTE .or
199 lexer_definition .emit DECLARATION_LEXER .or
200 rule_definition .emit DECLARATION_RULE;
203 <emitcode_definition> ::= ".emtcode" <identifier> <integer>
206 ".emtcode" .and space .and identifier .and space .and integer .and space_or_null;
209 <integer> ::= <integer_ne>
212 integer_ne .error INTEGER_EXPECTED;
215 <integer_ne> ::= <hex_integer>
219 hex_integer .emit 0x10 .or dec_integer .emit 10;
222 <hex_integer> :: <hex_prefix> <digit_hex> <digit_hex>*
225 hex_prefix .and digit_hex .emit * .and .loop digit_hex .emit * .and .true .emit '\0';
228 <hex_prefix> ::= "0x"
232 '0' .and hex_prefix_1;
237 <digit_hex> ::= "0"-"9"
242 '0'-'9' .or 'a'-'f' .or 'A'-'F';
245 <dec_integer> :: <digit_dec> <digit_dec>*
248 digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
251 <space_or_null> ::= <space>
258 <errortext_definition> ::= ".errtext" <identifier> <string>
261 ".errtext" .and space .and identifier .and space .and string .and space_or_null;
264 <string> ::= <string_ne>
267 string_ne .error STRING_EXPECTED;
270 <string_ne> ::= "\"" <string_char_double_quotes> "\""
273 '"' .and .loop string_char_double_quotes .and '"' .emit '\0';
276 <string_char_double_quotes> ::= <escape_sequence>
280 string_char_double_quotes
281 escape_sequence .or string_char .emit * .or '\'' .emit *;
284 <string_char> ::= All ASCII characters except "\'", "\"", "\n", "\r",
288 '\x5D'-'\xFF' .or '\x28'-'\x5B' .or '\x23'-'\x26' .or '\x0E'-'\x21' .or '\x0B'-'\x0C' .or
292 <escape_sequence> ::= "\\" <escape_code>
295 '\\' .emit * .and escape_code;
298 <escape_code> ::= <simple_escape_code>
303 simple_escape_code .emit * .or hex_escape_code .or oct_escape_code;
306 <simple_escape_code> ::= "\'"
319 '\'' .or '"' .or '?' .or '\\' .or 'a' .or 'b' .or 'f' .or 'n' .or 'r' .or 't' .or 'v';
322 <hex_escape_code> ::= "x" <digit_hex> <digit_hex>*
325 'x' .emit * .and digit_hex .emit * .and .loop digit_hex .emit *;
328 <oct_escape_code> ::= <digit_oct> <optional_digit_oct> <optional_digit_oct>
331 digit_oct .emit * .and optional_digit_oct .and optional_digit_oct;
334 <digit_oct> ::= "0"-"7"
340 <optional_digit_oct> ::= <digit_oct>
344 digit_oct .emit * .or .true;
347 <regbyte_definition> ::= ".regbyte" <identifier> <integer>
350 ".regbyte" .and space .and identifier .and space .and integer .and space_or_null;
353 <lexer_definition> ::= ".string" <identifier> ";"
356 ".string" .and space .and identifier .and semicolon;
359 <rule_definition> ::= <identifier_ne> <definition>
362 identifier_ne .and space .and definition;
365 <definition> ::= <specifier> <optional_specifiers_and_or> ";"
368 specifier .and optional_specifiers_and_or .and semicolon .emit SPECIFIER_END;
371 <optional_specifiers_and_or> ::= <and_specifiers>
375 optional_specifiers_and_or
376 and_specifiers .emit SPECIFIER_AND_TAG .or or_specifiers .emit SPECIFIER_OR_TAG .or .true;
379 <specifier> ::= <specifier_condition> <specifier_rule>
382 specifier_condition .and optional_space .and specifier_rule;
385 <specifier_condition> ::= ".if" "(" <left_operand> <operator> <right_operand> ")"
388 specifier_condition_1 .or .true;
389 specifier_condition_1
390 ".if" .and optional_space .and '(' .and optional_space .and left_operand .and operator .and
391 right_operand .and optional_space .and ')';
394 <left_operand> ::= <identifier>
404 operator_1 .or operator_2;
406 optional_space .and '!' .and '=' .and optional_space;
408 optional_space .and '=' .and '=' .and optional_space;
411 <right_operand> ::= <integer>
417 <specifier_rule> ::= <character_range> <optional_error> <emit>*
418 | <character> <optional_error> <emit>*
419 | <string> <optional_error> <emit>*
420 | ".true" <optional_error> <emit>*
421 | ".false" <optional_error> <emit>*
422 | ".debug" <optional_error> <emit>*
423 | <advanced_identifier> <optional_error> <emit>*
426 specifier_rule_1 .and optional_error .and .loop emit .and .true .emit EMIT_NULL;
428 character_range .emit SPECIFIER_CHARACTER_RANGE .or
429 character .emit SPECIFIER_CHARACTER .or
430 string_ne .emit SPECIFIER_STRING .or
431 ".true" .emit SPECIFIER_TRUE .or
432 ".false" .emit SPECIFIER_FALSE .or
433 ".debug" .emit SPECIFIER_DEBUG .or
434 advanced_identifier .emit SPECIFIER_IDENTIFIER;
437 <character> ::= "\'" <string_char_single_quotes "\'"
440 '\'' .and string_char_single_quotes .and '\'' .emit '\0';
443 <string_char_single_quotes> ::= <escape_sequence>
447 string_char_single_quotes
448 escape_sequence .or string_char .emit * .or '"' .emit *;
451 <character_range> ::= <character> "-" <character>
454 character .and optional_space .and '-' .and optional_space .and character;
457 <advanced_identifier> ::= <optional_loop> <identifier>
460 optional_loop .and identifier;
463 <optional_loop> ::= ".loop"
467 optional_loop_1 .emit IDENTIFIER_LOOP .or .true .emit IDENTIFIER_SIMPLE;
472 <optional_error> ::= <error>
476 error .emit ERROR_PRESENT .or .true .emit ERROR_NOT_PRESENT;
479 <error> :: ".error" <identifier>
482 space .and ".error" .and space .and identifier;
485 <emit> ::= <emit_output>
489 emit_output .or emit_regbyte;
492 <emit_output> ::= ".emit" <emit_param>
495 space .and ".emit" .and space .and emit_param;
498 <emit_param> ::= <integer>
505 integer_ne .emit EMIT_INTEGER .or
506 identifier_ne .emit EMIT_IDENTIFIER .or
507 character .emit EMIT_CHARACTER .or
508 '*' .emit EMIT_LAST_CHARACTER .or
509 '$' .emit EMIT_CURRENT_POSITION;
512 <emit_regbyte> ::= ".load" <identifier> <emit_param>
515 space .and ".load" .and space .and identifier .and space .and emit_param;
518 <and_specifiers> ::= <and_specifier> <and_specifier>*
521 and_specifier .and .loop and_specifier;
524 <or_specifiers> ::= <or_specifier> <or_specifier>*
527 or_specifier .and .loop or_specifier;
530 <and_specifier> ::= ".and" <specifier>
533 space .and ".and" .and space .and specifier;
536 <or_specifier> ::= ".or" <specifier>
539 space .and ".or" .and space .and specifier;
542 .string __string_filter;
545 <__string_filter> ::= <__first_identifier_char> <__next_identifier_char>*
548 __first_identifier_char .and .loop __next_identifier_char;
551 <__first_identifier_char> ::= "a"-"z"
556 __first_identifier_char
557 'a'-'z' .or 'A'-'Z' .or '_' .or '.';
560 <__next_identifier_char> ::= "a"-"z"
565 __next_identifier_char
566 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';