textX icon indicating copy to clipboard operation
textX copied to clipboard

Incorrect edge case in treating escaped characters in quoted strings

Open jhrmnn opened this issue 7 years ago • 2 comments

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.

jhrmnn avatar Mar 19 '18 10:03 jhrmnn

Er, sorry, this should have gone to Arpeggio, I guess.

jhrmnn avatar Mar 19 '18 10:03 jhrmnn

No problem. :)

Yes, It seems that you are right. I'll have to do some more investigation.

igordejanovic avatar Mar 20 '18 07:03 igordejanovic