I am currently trying to write my own compiler, targeting the JVM.
I have completed the parsing step using Java classes generated by ANTLR, and have an AST of the source code to work from (An ANTLR "CommonTree", specifically). I am using ASM to simplify the generating of the bytecode.
Could anyone give a broad overview of how to convert this AST to bytecode?
My current strategy is to explore down the tree, generating different code depending on the current node (using "Tree.getType()").
The problem is that I can only recognise tokens from my lexer this way, rather than more complex patterns from the parser.
Is there something I am missing, or am I simply approaching this wrong?