Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating antlr4 with LLVM

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.

like image 520
NewGirl Avatar asked Aug 20 '15 05:08

NewGirl


1 Answers

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.

like image 77
prmottajr Avatar answered Oct 24 '22 00:10

prmottajr