-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.sml
27 lines (23 loc) · 1017 Bytes
/
parse.sml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;
(* FindEscape.findEscape absyn; *)
(*Semant.transExp(Env.base_venv, Env.base_tenv, Translate.outermost, absyn); *)
(* print ("AST of " ^ filename ^ ":\n\n");
PrintAbsyn.print (TextIO.stdOut, absyn);
print "\n-------------------\n";*)
absyn
end handle LrParser.ParseError => raise ErrorMsg.Error
end