-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparse.sml
More file actions
23 lines (18 loc) · 806 Bytes
/
parse.sml
File metadata and controls
23 lines (18 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
structure Parse :> PARSE =
struct
structure AspectMLLrVals = AspectMLLrValsFun(structure Token = LrParser.Token)
structure AspectMLLex = AspectMLLexFun(structure Tokens = AspectMLLrVals.Tokens)
structure AspectMLParser = Join(structure ParserData = AspectMLLrVals.ParserData
structure Lex=AspectMLLex
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,p2) s
val lexer = LrParser.Stream.streamify (AspectMLLex.makeLexer get)
val (absyn, _) = AspectMLParser.parse(30,lexer,parseerror,())
in TextIO.closeIn file;
absyn
end handle LrParser.ParseError => raise ErrorMsg.Error
end