Add the tiger source code bundle from the book site
Signed-off-by: jmug <u.g.a.mariano@gmail.com>
This commit is contained in:
parent
915660c8a7
commit
33d8bac511
87 changed files with 3252 additions and 0 deletions
22
tiger/chap4/parse.sml
Normal file
22
tiger/chap4/parse.sml
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
structure Parse : sig val parse : string -> Absyn.exp end =
|
||||
struct
|
||||
structure TigerLrVals = TigerLrValsFun(structure Token = LrParser.Token)
|
||||
structure Lex = TigerLexFun(structure Tokens = TigerLrVals.Tokens)
|
||||
structure TigerP = Join(structure ParserData = TigerLrVals.ParserData
|
||||
structure Lex=Lex
|
||||
structure LrParser = LrParser)
|
||||
fun parse filename =
|
||||
let val _ = (ErrorMsg.reset(); ErrorMsg.fileName := filename)
|
||||
val file = TextIO.openIn filename
|
||||
fun get _ = TextIO.input file
|
||||
fun parseerror(s,p1,p2) = ErrorMsg.error p1 s
|
||||
val lexer = LrParser.Stream.streamify (Lex.makeLexer get)
|
||||
val (absyn, _) = TigerP.parse(30,lexer,parseerror,())
|
||||
in TextIO.closeIn file;
|
||||
absyn
|
||||
end handle LrParser.ParseError => raise ErrorMsg.Error
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue