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

Re-think CSTVisitor APIs #1039

Open
bd82 opened this issue Sep 7, 2019 · 2 comments
Open

Re-think CSTVisitor APIs #1039

bd82 opened this issue Sep 7, 2019 · 2 comments
Labels

Comments

@bd82
Copy link
Member

bd82 commented Sep 7, 2019

  • Cab the CSTVisitor avoid coupling to the Parser instance?
  • Can the default traversal be implemented as a fallback behavior instead of actual prototype methods?
  • Can the CST Visitor related validations be implemented as external utilities rather than methods?
  • Can we separate the validations of "all visit methods implemented" and "redundant visit methods found"?
  • Any additional CST related utilities that should be provided?
  • The CSTNode being visited is not accessible in each specific visit method
@bd82
Copy link
Member Author

bd82 commented Sep 17, 2020

More feedback from @matthew-dean

For visitor methods (https://sap.github.io/chevrotain/docs/tutorial/step3a_adding_actions_visitor.html#introduction), I would have expected that this.visit, if visiting an array, would return an array of visit results. However, that does not appear to be the case. I think this is one of those cases where there is non-intuitive behavior based on the structure of the CST. That is, the CST always produces children as arrays, for whatever reason, even if they only have one production. So maybe the typical scenario is that you would only visit arrays with a length of 1?

...Okay, just found the doc note: "If an array is passed (ctx.fromClause is an array) it is equivalent to passing the first element of that array"... IMO that should be called out in a dedicated section on arrays, with a convenience method such as visitArray to return an array of results.

@bd82
Copy link
Member Author

bd82 commented Aug 21, 2022

Can we separate the validations of "all visit methods implemented" and "redundant visit methods found"?

Redundant visit methods validation was removed in #1847

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant