I'm doing a compiler for study purpose.
It uses Antlr tool targeted for c# code generation.
So far, i can handle the gramar. Lexical, Sintatic, my tests are ok.
My aim is to generate CIL bytecode, i'm kinda familiar with it.
The problem is... I don't know a good way to "output" the code. I'd like some advice, example to generate it.
One thought i have, is to create a Class "compiler" with tons of method related to the node and call the method as the tree is iterated.
Ideia:
Class Compiler
{
private AppededStrings = "";
void CreateClass();
void EndClass();
void AddParam();
void setAtributeToTheClass("public");
... and so on ...
}
Is this a good approach? I could not find a topic talking specific about this.
Some parts of the page http://msdn.microsoft.com/en-us/magazine/cc136756.aspx will work for you :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With