alexjercan / compiler-tutorial

Compiler Tutorial in C

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compiler Tutorial in C

A really simple programming language meant to be used as a tutorial for compilers (really easy ones).

term = <input> | variable | literal
expression = term | term + term | ...
rel = term < term | ...
instr = variable = expression | <if> rel <then> instr | <goto> :label | <output> term | :label

Example of a program in this language

n = input
i = 0
:label
output i
i = i + 1
if i < n then goto :label
if i < 10 then goto :label2
output 69
:label2

Quickstart

gcc -g main.c -o main
cat example.txt | ./main > example.asm
fasm example.asm
./example

About

Compiler Tutorial in C

License:MIT License


Languages

Language:C 94.4%Language:Assembly 5.6%