-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An example showing significant whitespace? #643
Comments
As in multiple contiguous whitespace characters?
|
No, as in scopes delimited by indented sections of text (al a pug python haskell, etc.) |
Ah, so indent / dedent... that will be a context-aware parsing solution. Use local stateYou could get away with creating and updating a local context in the grammar post-processing step, eg.
This technique, however, will pose a few challenges and limitations, but it's one way to go about this without creating your own lexer. Use a custom lexerThis may perhaps be the more trivial way of parsing indent / dedent - as your sneaking suspicion was hinting to. (Haven't tried it myself yet.) I found the following on moo's issue tracker for context-aware indent / dedent parsing: no-context/moo#55 with the last link (moo-indentation-lexer) being the one you probably want. Then according to the nearley docs:
|
I'm having difficulty creating a parser for a language like Pug, I haven't tried using an external lexer, but I have a sneaking suspicion it is necessary.
Can you provide an example which shows how to do it?
The text was updated successfully, but these errors were encountered: