Skip to content

Latest commit

 

History

History
33 lines (27 loc) · 677 Bytes

File metadata and controls

33 lines (27 loc) · 677 Bytes

Compiler source code for a simple language

Simple language supports variables, arithmetic operations and printing to console and is compiled (translated) to C language

In order to compile the compiler you'll need gcc, flex and bison. To install them on Ubuntu:

sudo apt-get update
sudo apt-get install build-essential flex bison

Generate syntax analyzer code:

bison -d -o parser.c parser.y

Generate semantic analyzer code:

flex -o scanner.c scanner.l

Compile the compiler:

gcc -o compiler parser.c scanner.c ast.c -lfl

Compile any .mylang file:

./compiler example.mylang > example.c

View generated C code:

cat example.c