CPP lang is a static type-checked general purpose programming language and my very first programming language.
The language is similar to C but missing lots of important features such as:
- Arrays and pointers
- Structs and unions
- Syscalls and bindings with lib.c
- Native execution on x86 architectures
The grammar of the language can be found at CPP.cf.
- The frontend (lexer/parser) is defined at Lexer.x and Parser.y.
- The type checker is defined at TypeChecker.hs.
- The interpreter is defined at Interpreter.hs.
- The backend for the JVM is defined at JVM/CodeGenerator.hs.
The compiler is written in Haskell. You can build the compiler using both Cabal:
$ cabal build
or Stack:
$ stack build
Have a look at the files from examples. All of them can be executed on the interpreter.
$ cabal run CPP -- <name>.cc --interpreter
First, generate the *.jar
:
$ cabal run CPP -- <name>.cc --jvm
Then, run the *.jar
:
$ java -jar <name>.jar
- Arrays
- Pointers
- Add
char
as primitive type - =Value= should depend on =TExp=
- The JVM backend is not properly tested