~icefox/garnet#6: 
Parser improvement/refactor

  • ☑ Add span reporting to parser
  • ☑ Add any error messaging at all to lexer
  • ☐ Add comments -- basically, if we want to preserve comments, I think almost every decl/expr needs to become Either<Foo, Comment>. Or , like TypedExpr in 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.)
  • ☑ Add doc comments, which can just be a node attached to decl's
Status
REPORTED
Submitter
~icefox
Assigned to
No-one
Submitted
4 months ago
Updated
2 months ago
Labels
T-TODO

~icefox 2 months ago

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.)

Libs:

~icefox closed duplicate ticket #13 2 months ago

Register here or Log in to comment, or comment via email.