antlr-kotlin
antlr-kotlin copied to clipboard
$ symbol is not escaped properly in generated code
I'm trying to build a parser for MongoDB query expressions. The corresponding grammar has a lot of terminals which start with $
, e.g.:
-
$eq
-
$and
-
$not
- etc.
The problem is that the kotlin code generator does not escape those $
symbols properly. For example, in the generated lexer file, the LITERAL_NAMES
contains:
"'\"$and\"'"
... which of course translates to a template expression in Kotlin that inserts the value of the variable and
into the string. This is clearly not what we want. The proper escaping would be:
"\"${'$'}and\""