Clean up character and string literals in the lexer
This commit is contained in:
parent
c835fc9a79
commit
49f9e093e8
|
@ -1092,26 +1092,54 @@ BooleanLiteral
|
||||||
| 'false'
|
| 'false'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// §3.10.4 Character Literals
|
||||||
|
|
||||||
CharacterLiteral
|
CharacterLiteral
|
||||||
: '\'' ( EscapeSequence | ~('\''|'\\') ) '\''
|
: '\'' SingleCharacter '\''
|
||||||
;
|
| '\'' EscapeSequence '\''
|
||||||
|
;
|
||||||
|
|
||||||
|
fragment
|
||||||
|
SingleCharacter
|
||||||
|
: ~['\\]
|
||||||
|
;
|
||||||
|
|
||||||
|
// §3.10.5 String Literals
|
||||||
|
|
||||||
StringLiteral
|
StringLiteral
|
||||||
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
|
: '"' StringCharacters? '"'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
fragment
|
||||||
|
StringCharacters
|
||||||
|
: StringCharacter+
|
||||||
|
;
|
||||||
|
|
||||||
|
fragment
|
||||||
|
StringCharacter
|
||||||
|
: ~["\\]
|
||||||
|
| EscapeSequence
|
||||||
|
;
|
||||||
|
|
||||||
|
// §3.10.6 Escape Sequences for Character and String Literals
|
||||||
|
|
||||||
fragment
|
fragment
|
||||||
EscapeSequence
|
EscapeSequence
|
||||||
: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
|
: '\\' [btnfr"'\\]
|
||||||
| OctalEscape
|
| OctalEscape
|
||||||
;
|
;
|
||||||
|
|
||||||
fragment
|
fragment
|
||||||
OctalEscape
|
OctalEscape
|
||||||
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
|
: '\\' OctalDigit
|
||||||
| '\\' ('0'..'7') ('0'..'7')
|
| '\\' OctalDigit OctalDigit
|
||||||
| '\\' ('0'..'7')
|
| '\\' ZeroToThree OctalDigit OctalDigit
|
||||||
;
|
;
|
||||||
|
|
||||||
|
fragment
|
||||||
|
ZeroToThree
|
||||||
|
: [0-3]
|
||||||
|
;
|
||||||
|
|
||||||
// §3.10.7 The Null Literal
|
// §3.10.7 The Null Literal
|
||||||
|
|
||||||
|
|
|
@ -1176,26 +1176,54 @@ BooleanLiteral
|
||||||
| 'false'
|
| 'false'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// §3.10.4 Character Literals
|
||||||
|
|
||||||
CharacterLiteral
|
CharacterLiteral
|
||||||
: '\'' ( EscapeSequence | ~('\''|'\\') ) '\''
|
: '\'' SingleCharacter '\''
|
||||||
;
|
| '\'' EscapeSequence '\''
|
||||||
|
;
|
||||||
|
|
||||||
|
fragment
|
||||||
|
SingleCharacter
|
||||||
|
: ~['\\]
|
||||||
|
;
|
||||||
|
|
||||||
|
// §3.10.5 String Literals
|
||||||
|
|
||||||
StringLiteral
|
StringLiteral
|
||||||
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
|
: '"' StringCharacters? '"'
|
||||||
;
|
;
|
||||||
|
|
||||||
|
fragment
|
||||||
|
StringCharacters
|
||||||
|
: StringCharacter+
|
||||||
|
;
|
||||||
|
|
||||||
|
fragment
|
||||||
|
StringCharacter
|
||||||
|
: ~["\\]
|
||||||
|
| EscapeSequence
|
||||||
|
;
|
||||||
|
|
||||||
|
// §3.10.6 Escape Sequences for Character and String Literals
|
||||||
|
|
||||||
fragment
|
fragment
|
||||||
EscapeSequence
|
EscapeSequence
|
||||||
: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
|
: '\\' [btnfr"'\\]
|
||||||
| OctalEscape
|
| OctalEscape
|
||||||
;
|
;
|
||||||
|
|
||||||
fragment
|
fragment
|
||||||
OctalEscape
|
OctalEscape
|
||||||
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
|
: '\\' OctalDigit
|
||||||
| '\\' ('0'..'7') ('0'..'7')
|
| '\\' OctalDigit OctalDigit
|
||||||
| '\\' ('0'..'7')
|
| '\\' ZeroToThree OctalDigit OctalDigit
|
||||||
;
|
;
|
||||||
|
|
||||||
|
fragment
|
||||||
|
ZeroToThree
|
||||||
|
: [0-3]
|
||||||
|
;
|
||||||
|
|
||||||
// §3.10.7 The Null Literal
|
// §3.10.7 The Null Literal
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue