Closed gamagan closed 1 year ago
Hope this helps.
Thank you, at @yhirose. For posterity: I ended up boiling my version down to the following, for a string that accepts anything inside, plus the escaped sequences:
String <- '"' < ('\\\\' / '\\"' / (!["] .))* > '"'
What's the way to handle double quoted escape sequences?
I found a similar question: https://github.com/yhirose/cpp-peglib/issues/4 but that answer doesn't properly create C/C++ type of string escape sequences. Specifically, escaping a double quote requires an odd number of backslashes. An even number escapes the backslash itself.
The answer in the linked post would consider the following a complete string, but it should be a syntax error:
"abc\\"d"