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

Comments just generally get underfoot #394

Open
robrix opened this issue Feb 8, 2024 · 1 comment
Open

Comments just generally get underfoot #394

robrix opened this issue Feb 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@robrix
Copy link
Contributor

robrix commented Feb 8, 2024

Comments in the tree mess up all sorts of things. cf #371, #393, and others. We currently have to either make them into the lowest common denominator and add every scoped variable used anywhere to them, or make queries needlessly specific in what they'll match, which couples them overly tightly to the grammar and in any case doesn't work out so well for adjacency patterns (the ones with .s in them).

Most or all comments are unnecessary to stack graph rules, in that we aren't trying to resolve name lookups in or through them (although maybe we would want to jump to definition from within doctests or documentation comments), so maybe we could filter them out of the tree altogether?

@robrix robrix added the bug Something isn't working label Feb 8, 2024
@robrix
Copy link
Contributor Author

robrix commented Feb 9, 2024

To be precise, we have at least two problems stemming from the intrusion of comments:

  1. Queries matching multiple children of a given node will match comments as well, requiring antimodular treatment of the comment nodes (e.g. adding lots of scoped variables to them which are asemantic and treat comments as sort of the lowest common denominator since they can occur anywhere).
  2. Queries matching a single child of a given node, e.g. a parenthesized expression's… parenthesized… expression… will match comments as well, often requiring rules to be split into one which will run once for the given parent node, and one which will run for every child node (even though there is, semantically, only the one that matters).

TL;DR: We're working with a CST, we think of ourselves as working with an AST, bugs and hacks are the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant