Skip to content
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

Retain rule and alternation comments. #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kanaka
Copy link

@kanaka kanaka commented Apr 25, 2018

Suggestion for one possible approach to retaining comments in the parsed grammar (issue #178). This adds a new :comments field to nodes in the tree. Comments that are inside rules are attached to alternation nodes. Comments that are determined to be outside of rules (top-level) are attached to the next rule. The :comments value is a sequence of strings. Multiple comments at the same point in the grammar are separate strings in the :comments sequence. I'm new to the instaparse internals so this likely isn't the most optimal or least intrusive way to implement this so I'm proposing this to get a review/feedback on the change.

See test/instaparse/retain_comments.cljc for examples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant