|How to represent triple double quote string [message #1800977]
||Thu, 10 January 2019 14:55
| Henry Henry
Registered: January 2015
I am having some difficulties trying to declare triple double-quoted string and preventing it from conflicting with the existing single double-quoted string.
""" The reader says "The quick brown fox jumps over the lazy dog" while reading the book. """
Which should be accepted as a string similar to:
"The reader says \"The quick brown fox jumps over the lazy dog\" while reading the book."
This is common in some modern language like scala or kotlin. Basically when a string is declared inside triple double quoted string, any double quote or single quote does not need to be escaped.
Currently I tried using this
Where the terminals are defined as:
terminal STRING returns ecore::EString:
'"' ( '\\' ('b'|'t'|'n'|'f'|'r'|'"'|"'"|'\\') | !('\\'|'"') )* '"'
terminal TRIPLE_QUOTE_STRING returns ecore::EString:
'"""' ( '\\' ('b'|'t'|'n'|'f'|'r'|'"'|"'"|'\\') | !('\\'|'"') )* '"""'
However, it only works when there are no quote within the triple quote. It is not working whenever a quote is added inside the string.
Powered by FUDForum
. Page generated in 0.02139 seconds