mdaines / grammophone

A tool for analyzing and transforming context-free grammars.
https://mdaines.github.io/grammophone
MIT License
200 stars 23 forks source link

Parsing breaks when using "\" #47

Closed conspiracy0 closed 4 months ago

conspiracy0 commented 4 months ago

Easily testable, likely easily fixable. To reproduce, simply use:

S-> "\".

And a parser error will occur.

Additionally, trying S-> "\\". will result in an accurate parse for two \\ characters

mdaines commented 4 months ago

The Grammophone parser uses C-style escapes in strings, so "\\" (with two backslashes) is actually correct if you'd like a symbol that is a single backslash.

However, it doesn't properly unescape, so the symbol ends up appearing with the escape in the analysis views (when it should just be \). I'm working on a fix for that.

46 is related.

Thanks for reporting this; the current behavior is a bit confusing.

mdaines commented 4 months ago

I've deployed #48 and #49 which should address this.