textX
textX copied to clipboard
Incorrect edge case in treating escaped characters in quoted strings
I believe that the following is parsed incorrectly:
Python 3.6.4 (default, Mar 9 2018, 23:15:03)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(ins)>>> from textx.metamodel import metamodel_from_str
(ins)>>> mm = metamodel_from_str('Root: STRING;')
(ins)>>> mm.model_from_str(r"'\\' a'")
"\\' a"
In my understanding, \\ should be interpreted as a single backslash, the following ' should terminate the string, which should leave the hanging a' as non-parseable. At least that's what Python does.
Er, sorry, this should have gone to Arpeggio, I guess.
No problem. :)
Yes, It seems that you are right. I'll have to do some more investigation.