Closed apixandru closed 2 years ago
It turns out that this is not actually necessary if the escape sequence is
< CHARACTER_LITERAL:
"'"
// TODO: Could (and the duplicate code in STRING_LITERAL) this be extracted out?
(
(~["'","\\","\n","\r"])
|
// starts off with unicode backslash
("\\" "u" "0" "0" "5" ["c", "C"]
// regular escape sequences
(["n","t","b","r","f","\\","'","\""]
// escapes another unicode backslash
| ("\\" "u" "0" "0" "5" ["c", "C"])))
|
The below sequence is valid and should be properly parsed
When using the JavaParser library, I noticed that unicode escape sequences weren't properly escaped.
Their original grammar is here https://github.com/javaparser/javaparser/blob/master/javaparser-core/src/main/javacc/java.jj#L630
I tried modifying the character literals to what's below but then i got an error about having too many characters in a char.