-
Notifications
You must be signed in to change notification settings - Fork 54
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
Labeled element not being passed to action handler as property of element #28
Comments
Labelled elements only exist on nodes built by Canopy's default tree-building code. If you supply your own action, that means you're overriding that built-in behaviour, and you are given the elements of the match as an array. If you're writing in JS, you could use destructuring to improve the code: makeExpressionStatement(text, start, end, [_, expression]) {
// ...
} |
That would only be a minor cosmetic benefit - what I wanted it to do was return me the element nested at nth element deep, which would prevent me from having to make a nasty function that checks manually each vertebrae of the resulting tree to see if that is where the actually parsed element is found. |
I've inherited this grammar from PegJS, where it works just as described - instead of returning a whole tree of expressions that hand off the parsing until it meets the matching expression in question, it will simply return a literal, assignment expression or what have you all by itself as a single object |
Aha - there was actually a decent amount of javascript I was overlooking that accomplishes that for PegJS. I'll have to figure out how to make this work in Canopy minus labels. |
I have this rule that I would expect to provide 'Expression' as the property 'expression' on the appropriate element passed to the action handler, however it isn't showing up. Plenty of other rules have property labels on them and they show up just fine -- is there something I've missed here?
The text was updated successfully, but these errors were encountered: