Clean up character and string literals in the lexer
This commit is contained in:
parent
c835fc9a79
commit
49f9e093e8
|
@ -1092,25 +1092,53 @@ BooleanLiteral
|
|||
| 'false'
|
||||
;
|
||||
|
||||
CharacterLiteral
|
||||
: '\'' ( EscapeSequence | ~('\''|'\\') ) '\''
|
||||
;
|
||||
// §3.10.4 Character Literals
|
||||
|
||||
StringLiteral
|
||||
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
|
||||
CharacterLiteral
|
||||
: '\'' 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
|
||||
EscapeSequence
|
||||
: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
|
||||
: '\\' [btnfr"'\\]
|
||||
| OctalEscape
|
||||
;
|
||||
|
||||
fragment
|
||||
OctalEscape
|
||||
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
|
||||
| '\\' ('0'..'7') ('0'..'7')
|
||||
| '\\' ('0'..'7')
|
||||
: '\\' OctalDigit
|
||||
| '\\' OctalDigit OctalDigit
|
||||
| '\\' ZeroToThree OctalDigit OctalDigit
|
||||
;
|
||||
|
||||
fragment
|
||||
ZeroToThree
|
||||
: [0-3]
|
||||
;
|
||||
|
||||
// §3.10.7 The Null Literal
|
||||
|
|
|
@ -1176,25 +1176,53 @@ BooleanLiteral
|
|||
| 'false'
|
||||
;
|
||||
|
||||
CharacterLiteral
|
||||
: '\'' ( EscapeSequence | ~('\''|'\\') ) '\''
|
||||
;
|
||||
// §3.10.4 Character Literals
|
||||
|
||||
StringLiteral
|
||||
: '"' ( EscapeSequence | ~('\\'|'"') )* '"'
|
||||
CharacterLiteral
|
||||
: '\'' 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
|
||||
EscapeSequence
|
||||
: '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\')
|
||||
: '\\' [btnfr"'\\]
|
||||
| OctalEscape
|
||||
;
|
||||
|
||||
fragment
|
||||
OctalEscape
|
||||
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
|
||||
| '\\' ('0'..'7') ('0'..'7')
|
||||
| '\\' ('0'..'7')
|
||||
: '\\' OctalDigit
|
||||
| '\\' OctalDigit OctalDigit
|
||||
| '\\' ZeroToThree OctalDigit OctalDigit
|
||||
;
|
||||
|
||||
fragment
|
||||
ZeroToThree
|
||||
: [0-3]
|
||||
;
|
||||
|
||||
// §3.10.7 The Null Literal
|
||||
|
|
Loading…
Reference in New Issue