Open lgo opened 6 years ago
Another thing that would be interesting to implement in the typical visitor is context building, just in the form of basics such as recording @current_class
upon entering and exiting a class or interface decl. It's used pretty generically in a few name resolution and typing visitors.
Also, I just realized you can do
def visit(node : ClassDecl)
# entry code
super
# exit code
end
To handle things, as opposed to having entry/exit specific stuff :).
[ ] Clean up the AST
[ ] Pointer to parent node (easy to implement with a visitor, if you're ok with
#parent
being nilable)[ ] expr not subclass of stmt
[x] re-visit modifiers, make them a string instead and remove the AST
[x] destroy TMPMethodDecl
[ ] make
AST::Param
wrap anAST::VariableDecl
[ ] exprop -> abstract, unaryop class, binaryop class
[ ] squish
AST::FieldDeclStmt
withAST::FieldDecl
andAST::VarDeclStmt
[ ] Flatten some nodes
[ ] DeclStmt and FieldDecl. These have similar contents, so maybe they can just be merged.
[ ] File and PackageDecl.
[x] Clean up variable and class names, e.g.
ExprClassInit
andExprArrayCreation
are inconsistent.Typing::Types::Reference
should beTyping::Types::Instance
[ ] Rip out common logic like types. Can we make declaration
to_type
shared?[x] Write an actual AST print. Being able to see the AST 1:1 of the actual tree would be so helpful. (edited)
[x] Dealing with RHS variables. Do we also wrap then with a Variable node?
[ ] figure out how to deal with complicated fields it method invocations. E.g.
(variable.GetThing()).x.y
, what is that in the parse tree or AST and how do we fix or handle it.[ ] Coming up with well-defined subsystems. Like what I started with
Typing
that is included.[ ] Clean up the file structure. Probably breaking out some things into folders for the subsystems. Name resolution is a bit long and very messy
[x] Clean up Crystal-isms. e.g.
<Type> | Nil
=><Type>?
[ ] A way to make sure that Visitor has methods for all AST nodes?
[ ] precompute/cache class hierarchy relationships (implements/extends)
[ ] Make operators ENUMs instead of strings
[ ] Correctly implement
Lexeme#to_s
[ ] Can we change Simplification so that
AST::Name
s don't have to be returned asAST::ExprRef
s?[ ] Visitor cleanup
ast_children
to accept method?AST::Node
instead of every concrete node[ ] We probably don't understand ambiguous names fully. Need to do a read of the JLS (6.5) and re-visit name resolution
There's also the argument of trying to either rip out the logic for all of one sub-system (e.g. pretty printing) to one file or keeping it all in one.
It's currently pretty messy and longer so I'm actually leaning towards ripping it out. My biggest concern is that you now have to reference two files at all times. The pro is it's much easier to navigate the raw AST structure.