Debian Codegraph @

lib/mllpt-lib/ml-lpt/ml-antlr/FrontEnds/ml-yacc-based/parse-file.sml

raw
1 (* parse-file.sml
2 *
3 * COPYRIGHT (c) 2006
4 * John Reppy (http://www.cs.uchicago.edu/~jhr)
5 * Aaron Turon (http://www.cs.uchicago.edu/~adrassi)
6 * All rights reserved.
7 *
8 * Driver for the parser.
9 *)
10
11 structure ParseFile =
12 struct
13
14 (* glue together the lexer and parser *)
15 structure LLKLrVals = MLYLrValsFun (structure Token = LrParser.Token)
16 structure LLKLex = MLYLexFn (structure Tok = LLKLrVals.Tokens)
17 structure LLKParser = JoinWithArg(
18 structure ParserData = LLKLrVals.ParserData
19 structure Lex = LLKLex
20 structure LrParser = LrParser)
21
22 (* parse a file, returning a parse tree *)
23 fun parse' (startGrm, filename) = let
24 val _ = Err.status ("parsing " ^ filename)
25 val file = TextIO.openIn filename
26 fun get n = TextIO.inputN (file, n)
27 val lexer = LLKParser.makeLexer get (Err.lexErr filename)
28 in
29 #1(LLKParser.parse
30 (15, lexer, Err.parseErr filename,
31 (Err.parseErr filename, startGrm, parse')))
32 before TextIO.closeIn file
33 end
34
35 fun parse filename = parse'(GrammarSyntax.mkGrammar(), filename)
36
37 end