diff options
Diffstat (limited to '_tests/antlr.bnf')
| -rw-r--r-- | _tests/antlr.bnf | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/_tests/antlr.bnf b/_tests/antlr.bnf new file mode 100644 index 0000000..7b0cf83 --- /dev/null +++ b/_tests/antlr.bnf @@ -0,0 +1,99 @@ +grammar ExprLexer; + +LF : '\n' ; +SP : ' ' ; +WS_CC : [\t\r\f] ; +SEMI : ';' ; +DOT : '.' ; +COLON : ':' ; +PIPE : '|' ; +TILDE : '~' ; +BSLASH : '\\' ; +DQUOTE : '"' ; +HASH : '#' ; +LPAREN : '(' ; +RPAREN : ')' ; +LSQBR : '[' ; +RSQBR : ']' ; +LCURLY : '{' ; +RCURLY : '}' ; +EQUAL : '=' ; +APOS : '\'' ; +GRAVE : '`' ; +COMMA : ',' ; + + : [\u0000-\u0009\u000b-\u00ff] ; + +BARE_CHAR : [a-zA-Z0-9!$%&*+/<=>?@^_~-] | '\\' BARE_ESC ; + +BARE_ESC : [\u0021-\u007e] ; + +QUOTED_CHAR : [^"\\] | '\\' QUOTED_ESC ; + +QUOTED_ESC : [\\"abefnrtv] + | 'x' HEX_DIGIT HEX_DIGIT + | 'u' '{' HEX_DIGIT+ '}' + ; + + +HEX_DIGIT : [0-9a-fA-F] ; +ALPHA : [a-zA-Z] ; +ALNUM : [a-zA-Z0-9] ; + + + +parse_unit : blank* datum blank? ; + + +blank : LF | SP | WS_CC | comment ; + +datum : datum_one ( join_char? datum )? ; + + +comment : ';' ( skip_datum | skip_line ) ; + + +datum_one : bare_string | fancy_datum ; + +join_char : '.' | ':' | '|' ; + + +skip_datum : '~' parse_unit ; + +skip_line : ANY_BUT_LF* LF? ; + + +bare_string : BARE_CHAR+ ; + +fancy_datum : '\\' bare_esc_str + | '"' quoted_str '"' + | '#' hash_expr + | '(' list_body ')' + | '[' list_body ']' + | '{' list_body '}' + | quote_expr + ; + + +bare_esc_str : '\\' BARE_ESC BARE_CHAR* ; + +quoted_str : QUOTED_CHAR* ; + +hash_expr : rune fancy_datum? + | label ( '=' fancy_datum )? + | fancy_datum + ; + +list_body : blank* ( list_head list_tail? )? ; + +quote_expr : ( '\'' | '`' | ',' ) datum ; + + +rune : ALPHA ALNUM* ; + +label : '%' HEX_DIGIT+ ; + + +list_head : datum blank* list_head? ; + +list_tail : blank+ '.' blank+ datum blank* ; |
