I have a rule for parsing quoted strings that looks like this:
::= <"\"">
string ::= quote #"[^\"]*" quote
but I have a use-case now where the strings can potentially be stringified json and thus contain escaped quotes that break the above rule, for example
"{\"k\": 1}"
I am trying to devise a new rule that handles this, but am struggling. I’ve looked at things like negative lookahead, as so
::= <#"(?
string ::= quote (!quote)* quote
But this doesn’t seem to work and I’m not sure what else I could do. Any ideas?