-
Notifications
You must be signed in to change notification settings - Fork 239
Open
Description
What's up?
We discussed comments (and associated aesthetic items, such as significant newlines) on Discord. A couple of options for how to do this:
- Add to the AST — change the Parser to parse comments, attaching them to AST nodes. For example, there would be a
comments
field on the Expr struct containing the comments before the expression.- This keeps context local — each node can format itself without requiring the context of the full query
- But it would mean lots of changes to the parser. Some nodes aren't
Expr
and so would require a different design (e.g. a comment above an annotation wouldn't fit anywhere; similarly we'd need to add this toStmt
too.)
- Require passing in the source into
WriteSource
, use the source to find and write the comments while writing the query.- This is less dev work, because comments don't need to go through the PL.
- But it means formatting something requires global context, which is less modular and harder to maintain
IIUC these are the main two approaches. There are variations — for example having comments part of a CST but not AST; though in our case we don't have a CST.
Any thoughts?
Metadata
Metadata
Assignees
Labels
No labels