Skip to content

Kampbell/article-llvm-rpg

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A tutorial on how to write a compiler using LLVM

The project requires the LLVM librariaries installed see https://llvm.org/docs/GettingStarted.html#getting-started-with-llvm.

Project Structure

.
├── bin           
│   └── antlr-4.8-complete.jar   // ANTLR4 tool
|
├── rpgle           
│   └── CALCFIB.rpgle   // Sample RPG file
├── src             
│   ├── antlr           // ANTLR4 grammar files
│   ├── generated       // ANTLR4 generated parser/lexer
│   └── rpg             // C++ source code
│      
└── CMakeLists.txt      // CMake file

Compile and run

CMake

article-llvm-rpg$ cmake .

Build the project

article-llvm-rpg$ make -j2 

Run the sample

article-llvm-rpg$ ./rpg rpgle/CALCFIB.rpgle 

Generate parser and lexer

The ANTLR4 lexer and parser are already included in the source code, the antlr .jar file required to is available in the bin directory. To re generate the lexer and the parser:

article-llvm-rpg$ java -cp ./bin/antlr-4.8-complete.jar org.antlr.v4.Tool -Dlanguage=Cpp -listener -visitor -o src/generated/ -Xexact-output-dir -package antlrcpprpg src/antlr/RpgLexer.g4 src/antlr/RpgParser.g4

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 94.7%
  • ANTLR 2.6%
  • CMake 1.0%
  • C 0.5%
  • Makefile 0.5%
  • Objective-C++ 0.5%
  • Other 0.2%