keriwarr / orangejoos

JOOS1W Compiler, written in Crystal
0 stars 1 forks source link

Cleanup #21

Open lgo opened 6 years ago

lgo commented 6 years ago

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.

lgo commented 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 :).