Compiler

Hi guys.I have a problem about compiler.I want to write a simple compiler for a language.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
stm -> id := expr 
 | print expr 
 | if expr then stm 
 | while expr do stm 
 | begin opt_stmts end 
 
opt_stms -> stmt_list 
 | ε 
 
stmt_list -> stmt_list ; stm 
 | stm 
 
expr -> term moreterms 
 
moreterms -> + term moreterms 
 | - term moreterms 
 | ε 
 
term -> factor morefactors 
 
morefactors -> * factor morefactors 
 | / factor morefactors 
 | div factor morefactors 
 | mod factor morefactors 
 | ε 
 
factor -> ( expr ) 
 | id 
 | num 
 

The thing that I want to learn is Where I should start.Please help

I guess I should create main.c to convert source code.Also,I should create a source.c to write a example program that is relevant with above grammer. Do you have any idea?
Last edited on
http://llvm.org/docs/tutorial/
^ one of the greatest tutorials i have found for building a JIT compiler
Topic archived. No new replies allowed.