simpleb
Last updated 22nd Aug 2007
Simpleb is a compiler for a subset of C. It is programmed in ocaml and supports loops and conditionals. However, it does not support arrays, pointers or functions. It is possible to call external functions (e.g. printf).
The parser and grammar are created using ocamllex and ocamlyacc.
The compiler only converts the source code into assembly. An assembler (e.g. nasm) is then required to compile the assembly code into an object file. Finally a linker (e.g. gcc or ld) is required to link the object files into a binary application.
Downloads
- simpleb language specification
- source code + samples (Licensed under GPL)
- source code (browsable)
- sample 1: find a number in a given range that has the longest Collatz sequence
- sample 2: Calculate the GCD of two numbers
- sample 3: Display the first 100 prime numbers
- sample 4: Find a self descriptif number
Using the compiler
on gentoo linux
emerge dev-lan/nasm
emerge dev-lang/ocaml
tar xvfz simpleb.tar.gz
cd simpleb
make
make filename.sim
./samples/filename.out