Rascal is an LLVM-based compiler written in Rust for a small subset of Pascal with full debug support.
Rascal has been written with focus on learning Rust and generation of debug information with LLVM. So far, little effort has been spent to make it work on multiple platforms, be easy to build or be easy to use.
Currently Rascal works only on Linux x86_64.
Requirements:
- Rust built from the HEAD of the master branch, in particular:
- the compiler:
rustc - LLVM bindings module:
$RUST_DIR/src/librustc/lib/llvm.rs - LLVM library for Rust:
$RUST_DIR/rustllvm/x86_64-unknown-linux-gnu/librustllvm.so - LLVM target code generation tool
llcthat is built together with Rust:$RUST_DIR/llvm/x86_64-unknown-linux-gnu/$BUILD_TYPE/llc(where$BUILD_TYPEis the type of LLVM build process, eg.Release+Asserts)
- the compiler:
Steps:
- Copy
Makefile.intoMakefile. - Fill
Makefilewith your path to the directory with the LLVM library for Rust (librustllvm.so). - Copy
rascal.rc.intorascal.rc. - Fill
rascal.rcwith your path to the LLVM bindings module (llvm.rs). - Run
make.
Steps:
- Modify
LD_LIBRARY_PATHenvironment variable to contain the directory with the LLVM library for Rust (librustllvm.so). - Run
rascal <file>.pas. It will produce<file>.bccontaining LLVM bitcode with full debug information. - Run
llc <file>.bc. It will produce<file>.swith the assembly code. - Run
gcc -g <file>.s runtime.c(alternatively clang may be used) to generate the executable with full debug information.runtime.cis the "standard library" of Rascal.
The steps 2-4 can be executed at once using the compile.sh script.
- All identifiers are lower cased (Pacal is case-insensitive).
- The main block of a program is compiled as the
main()function.
Rascal is distributed under the terms of the MIT License. See LICENSE
file for details.