-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparse.sml
26 lines (20 loc) · 855 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
structure Parser =
struct
structure CLrVals = CLrValsFun(structure Token = LrParser.Token);
structure CLex = CLexFun(structure Tokens = CLrVals.Tokens);
structure CParser = Join(
structure ParserData = CLrVals.ParserData
structure Lex = CLex
structure LrParser = LrParser);
exception CError;
fun parse fileName =
let val inStream = TextIO.openIn fileName
fun readNext n = if TextIO.endOfStream inStream then ""
else TextIO.inputN (inStream, n)
val lexer = CParser.makeLexer readNext
fun printError (msg,line,col) = print (fileName ^ "[" ^ Int.toString line ^ "] " ^msg^ "\n")
val (ans,_) = CParser.parse (15, lexer, printError, ())
in
ans
end
end