Tiger Compiler Project
By Mu Li
2007-3-8Li, Mu ([email protected]) 2
We assume you are familiar with according theory backgrounds mentioned in dragon book (or tiger book)
2007-3-8Li, Mu ([email protected]) 3
Use CUP to implement the parser◦Easy◦Only grammar specification is needed
2007-3-8Li, Mu ([email protected]) 5
Notice %Cup in your tiger.flex, which make Jflex implement java_cup.runtime.Scanner
2007-3-8Li, Mu ([email protected]) 8
Run CUP, parser.java and sym.java obtained
More information, you should read the documents provided by Jflex and CUP
2007-3-8Li, Mu ([email protected]) 9
Tree’s nodes are defined in tiger.absyn
Your should make your compiler know the structure by CUP
2007-3-8Li, Mu ([email protected]) 12
…
…
let type a=btype b=ctype c=intvar x:a:=3
in a:=“hello world”
end
2007-3-8Li, Mu ([email protected]) 16
let
type arrtype = array of inttype rectype = {name:string, id: int}
var rec := rectype {name="aname", id=0}var arr := arrtype [3] of 0
inif rec <> arr then 3 else 4
end
2007-3-8Li, Mu ([email protected]) 19
2007-3-8Li, Mu ([email protected]) 21
2007-3-8Li, Mu ([email protected]) 22
2007-3-8Li, Mu ([email protected]) 23
2007-3-8Li, Mu ([email protected]) 24
You should print the AST and check the types
The specification is on our website Deadline is 30th Mar. NO cheating!
2007-3-8Li, Mu ([email protected]) 25