WMOC is a learning project about compiler design and construction. It’s based on PL/0, formulated by Niklaus Wirth as a minimal educational language. Followed from the brilliant blog series written by Brian Callahen.
PL/0 (or pl0) is an "educational programming language" as stated by Rosetta Code. The syntax rule of the language can be represented in the EBNF form as:
program = block "." .
block = [ "const" ident "=" number { "," ident "=" number } ";" ]
[ "var" ident { "," ident } ";" ]
{ "procedure" ident ";" block ";" } statement .
statement = [ ident ":=" expression
| "call" ident
| "begin" statement { ";" statement } "end"
| "if" condition "then" statement
| "while" condition "do" statement ] .
| "printInt" ident
| "printChar" into ident
| "readInt" into ident
condition = "odd" expression
| expression ( "=" | "#" | "<" | ">" ) expression .
expression = [ "+" | "-" ] term { ( "+" | "-" ) term } .
term = factor { ( "*" | "/" ) factor } .
factor = ident
| number
| "(" expression ")" .
ident = "A-Za-z_" { "A-Za-z0-9_" } .
number = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" .
In this first version, WMOC works as a front end. It generates intermediate C code from .pl0 source files. You can then compile the generated C code with any C compiler (like gcc).
Source Code -> Lexer -> Parser -> Semantic Analyser -> C Code Generation
- Download the executable
wmocfrom releases. - Run:
./wmoc <your-.pl0-file> <output.c-filename- This will generate a
.cfile. Then compile and run it with:
gcc <output.c> && ./a.out- Clone the repository:
git clone https://github.com/Gamin8ing/wmoc.git
cd wmoc- Build using:
make- An executable named
wmocwill be created. - To use it:
./wmoc <your-file.pl0> <output.c>- Then compile and run it with:
gcc <output.c> && ./a.outAn example .pl0 file is included in the source code (example.pl0).
./wmoc example.pl0 example.c
gcc example.c -o example && ./example
To report bugs or request features, please open an issue using our issue template mentioned in CONTRIBUTION.md. We appreciate feedback and contributions!