1(* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi
2 *
3 * $Log$
4 * Revision 1.1  2006/06/22 07:40:27  michaeln
5 * Add a MoscowML compilable implementation of MLyacc, using the MLton sources
6 * as the base.
7 *
8 * Revision 1.2  1997/05/23 16:21:10  dbm
9 *   SML '97 sharing, where clauses.
10 *
11# Revision 1.1.1.1  1997/01/14  01:38:06  george
12#   Version 109.24
13#
14 * Revision 1.2  1996/02/26  15:02:38  george
15 *    print no longer overloaded.
16 *    use of makestring has been removed and replaced with Int.toString ..
17 *    use of IO replaced with TextIO
18 *
19 * Revision 1.1.1.1  1996/01/31  16:01:46  george
20 * Version 109
21 *
22 *)
23
24functor ParseGenParserFun(structure Header : HEADER
25			  structure Parser : ARG_PARSER
26			    where type pos = Header.pos
27			  sharing type Parser.result = Header.parseResult
28			  sharing type Parser.arg = Header.inputSource =
29			                  Parser.lexarg
30			 ) : PARSE_GEN_PARSER =
31
32 struct
33      structure Header = Header
34      val parse = fn file =>
35          let
36	      val in_str = TextIO.openIn file
37	      val source = Header.newSource(file,in_str,TextIO.stdOut)
38	      val error = fn (s : string,i:int,_) =>
39		              Header.error source i s
40	      val stream =  Parser.makeLexer (fn i => (TextIO.inputN(in_str,i)))
41		            source
42	      val (result,_) = (Header.lineno := 1;
43				Header.text := nil;
44		                Parser.parse(15,stream,error,source))
45	   in (TextIO.closeIn in_str; (result,source))
46	   end
47  end;
48