Skip to content

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