0

I started using ANTLR 4 for my compiler course and I already created my grammar. ANTLR gives me the Lexer and the Parser but how can I generate an intermediate code? Someone told me to use Jasmin but I did't know how to use it.

NB: ANTLR gives me the java code.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Tadesse
  • 76
  • 2
  • 4
  • 2
    What is "intermediate code"? – Vampire Aug 11 '16 at 13:33
  • @Vampire https://en.wikipedia.org/wiki/Intermediate_representation#Intermediate_language – Vince Aug 11 '16 at 13:36
  • So you mean how to generate the Java bytecode out of your custom language that you parsed with your ANTLR parser / lexer? If so, then you should write so. ;-) – Vampire Aug 11 '16 at 14:09
  • @Tadesse: Your compiler class doesn't have theory and lecture on how to define and build intermediate code? You must have an awful compiler class. Get any textbook on compilers (Aho/Ullman/Sethi "Compiler") and *read* the chapters on this topic. You still have work to do, but with the principles understood this is a matter of programming. – Ira Baxter Aug 13 '16 at 15:10
  • @Vampire: or, if OP didn't mean "Java bytecode", to leave that out because it isn't relevant. I think Vince's answer defines it in a way that is more in line with a classic compiler course. – Ira Baxter Aug 13 '16 at 15:12
  • Here is a tutorial: https://www.youtube.com/playlist?list=PLOfFbVTfT2vbJ9qiw_6fWwBAmJAYV4iUm It is german, but has english subtitles (disclaimer: I am the author) – yankee Jul 01 '17 at 17:53

1 Answers1

1

As you was told, Jasmin is one way to generate the bytecode.
If you don't know how to use it, I suggest you learn how to use it.
For example read the User Guide.
If you have some more specific problem / question you can come back here to SO and ask. But please read and obey https://stackoverflow.com/help/how-to-ask

Community
  • 1
  • 1
Vampire
  • 35,631
  • 4
  • 76
  • 102