I am developing a compiler using ANTLR and LLVM. I have already implemented a lexer and a parser using ANTLR 4's Eclipse IDE. I want to implement a semantic analyzer and a code generator using LLVM. For this I want to know how to integrate the two. Most of the projects that I have seen online use ANTLR for semantic analysis (with visitor and walker functions) and LLVM for code generation only. I want to know how to pass ANTLR parser output as input to LLVM semantic analyser. Links to online examples illustrating this would be very useful.
Although you mentioned ANTLR4 there is an example of using ANTLR3 to generate LLVM IR for a subset of C here https://theantlrguy.atlassian.net/wiki/spaces/ANTLR3/pages/2687062/LLVM It is very interesting and presents an example of how to use both tools together to create a working compiler.
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