feat/schema: additional literal types
This commit is contained in:
@@ -1,15 +1,43 @@
|
||||
string: '`' {.} '`' | '"' {.} '"';
|
||||
_raw_string: '`' {.} '`';
|
||||
_interpreted_string: '"' {.} '"';
|
||||
string: _raw_string | _interpreted_string;
|
||||
|
||||
_unicode_value: . | _little_u_value | _big_u_value | _escaped_char;
|
||||
_byte_value: _octal_byte_value | _hex_byte_value;
|
||||
_little_u_value: '\\' 'u' _hex_digit _hex_digit _hex_digit _hex_digit;
|
||||
_big_u_value: '\\' 'U' _hex_digit _hex_digit _hex_digit _hex_digit _hex_digit _hex_digit _hex_digit _hex_digit;
|
||||
_escaped_char: '\\' ('a' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' | '\\' | '\'' | '"');
|
||||
_octal_byte_value: '\\' _oct_digit _oct_digit _oct_digit;
|
||||
_hex_byte_value: '\\' 'x' _hex_digit _hex_digit;
|
||||
rune: '\'' (_unicode_value | _byte_value) '\'';
|
||||
|
||||
_bin_digit: '0' - '1';
|
||||
_bin_digits: _bin_digit {_bin_digit | '_'};
|
||||
_oct_digit: _bin_digit | '2' - '7';
|
||||
_oct_digits: _oct_digit {_oct_digit | '_'};
|
||||
_dec_digit: _oct_digit | '8' - '9';
|
||||
_dec_digits: _dec_digit {_dec_digit | '_'};
|
||||
_hex_digit: _dec_digit | 'A' - 'F' | 'a' - 'f';
|
||||
number: ['-' | '+'] '0' 'b' _bin_digit {_bin_digit | '_'}
|
||||
| ['-' | '+'] '0' 'o' _oct_digit {_oct_digit | '_'}
|
||||
| ['-' | '+'] _dec_digit {_dec_digit | '_'}
|
||||
| ['-' | '+'] '0' 'x' _hex_digit {_hex_digit | '_'};
|
||||
_hex_digits: _hex_digit {_hex_digit | '_'};
|
||||
|
||||
_name_initial: 'A' - 'Z' | 'a' - 'z' | '_' | '~' | '!' | '@' | '#' | '$' | '%' | '^' | '&' | '*' | '-' | '_' | '+' | '=' | '?' | '/' | '.' | '\'';
|
||||
_int: ['-' | '+'] '0' ('b' | 'B') _bin_digits
|
||||
| ['-' | '+'] '0' ('o' | 'O') _oct_digits
|
||||
| ['-' | '+'] _dec_digits
|
||||
| ['-' | '+'] '0' ('x' | 'X') _hex_digits;
|
||||
int: _int;
|
||||
_dec_exponent: ('e' | 'E') ['+' | '-'] _dec_digits;
|
||||
_dec_float: ['-' | '+'] _dec_digits '.' [_dec_digits] [_dec_exponent]
|
||||
| _dec_digits _dec_exponent
|
||||
| '.' _dec_digits [_dec_exponent];
|
||||
|
||||
_hex_exponent: ('p' | 'P') ['+' | '-'] _dec_digits;
|
||||
_hex_mantissa: ['_'] _hex_digits '.' _hex_digits | ['_'] _hex_digits | '.' _hex_digits;
|
||||
_hex_float: ['-' | '+'] '0' ('x' | 'X') _hex_mantissa _hex_exponent;
|
||||
_float: _dec_float | _hex_float;
|
||||
float: _float;
|
||||
imaginary: (_dec_digits | _int | _float) 'i';
|
||||
|
||||
_name_initial: 'A' - 'Z' | 'a' - 'z' | '_' | '~' | '!' | '@' | '#' | '$' | '%' | '^' | '&' | '*' | '-' | '_' | '+' | '=' | '?' | '/' | '.';
|
||||
_name_char: _name_initial | _dec_digit;
|
||||
name: _name_initial {_name_char};
|
||||
|
||||
@@ -33,7 +61,10 @@ ValList
|
||||
;
|
||||
Val
|
||||
: string <<ast.NewStringVal($T0)>>
|
||||
| number <<ast.NewNumberVal($T0)>>
|
||||
| rune <<ast.NewRuneVal($T0)>>
|
||||
| int <<ast.NewIntVal($T0)>>
|
||||
| float <<ast.NewFloatVal($T0)>>
|
||||
| imaginary <<ast.NewComplexVal($T0)>>
|
||||
| name <<ast.NewNameVal($T0)>>
|
||||
| Expr <<ast.NewExprVal($0)>>
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user