Either<Foo, Comment>. Or , like
TypedExprin the IR, become a struct containing both the node and auxiliary info -- I think that has to happen anyway to contains
Span's, so that might give us a convenient place to hang comments as well. (Update: Currently comments are just skipped between the lexer and parser, not too hard after all.)
Currently the AST is very simple, just a tree of nodes with no idea what the original source is. There's two issues with this:
- Error reporting. We need nodes to have code spans pointing to the original text.
- Comments get lost. It would be nice to have comments preserved so we can trivially make a re-formatter. But since comments can be anywhere, basically, this gets annoying with designing the AST and parser. (Doc comments are somewhat different 'cause they can only be at fixed places in the syntax tree anyway.)