Clean up character and string literals in the lexer
This commit is contained in:
parent
c835fc9a79
commit
49f9e093e8
|
@ -1092,25 +1092,53 @@ BooleanLiteral
|
||||||
| 'false'
|
| 'false'
|
||||||
;
|
;
|
||||||
|
|
||||||
CharacterLiteral
|
// §3.10.4 Character Literals
|
||||||
: '\'' ( EscapeSequence | ~('\''|'\\') ) '\''
|
|
||||||
;
|
|
||||||
|
|
||||||
StringLiteral
|
CharacterLiteral
|
||||||
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
|
: '\'' SingleCharacter '\''
|
||||||
|
| '\'' EscapeSequence '\''
|
||||||
;
|
;
|
||||||
|
|
||||||
|
fragment
|
||||||
|
SingleCharacter
|
||||||
|
: ~['\\]
|
||||||
|
;
|
||||||
|
|
||||||
|
// §3.10.5 String Literals
|
||||||
|
|
||||||
|
StringLiteral
|
||||||
|
: '"' 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,25 +1176,53 @@ BooleanLiteral
|
||||||
| 'false'
|
| 'false'
|
||||||
;
|
;
|
||||||
|
|
||||||
CharacterLiteral
|
// §3.10.4 Character Literals
|
||||||
: '\'' ( EscapeSequence | ~('\''|'\\') ) '\''
|
|
||||||
;
|
|
||||||
|
|
||||||
StringLiteral
|
CharacterLiteral
|
||||||
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
|
: '\'' SingleCharacter '\''
|
||||||
|
| '\'' EscapeSequence '\''
|
||||||
;
|
;
|
||||||
|
|
||||||
|
fragment
|
||||||
|
SingleCharacter
|
||||||
|
: ~['\\]
|
||||||
|
;
|
||||||
|
|
||||||
|
// §3.10.5 String Literals
|
||||||
|
|
||||||
|
StringLiteral
|
||||||
|
: '"' 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