Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* Modified by Vesa Karvonen on 2007-12-18. |
2 | * Create line directives in output. | |
3 | *) | |
4 | (* ML-Yacc Parser Generator (c) 1989 Andrew W. Appel, David R. Tarditi *) | |
5 | ||
6 | functor ParseGenParserFun(structure Header : HEADER | |
7 | structure Parser : ARG_PARSER | |
8 | where type pos = Header.pos | |
9 | sharing type Parser.result = Header.parseResult | |
10 | sharing type Parser.arg = Header.inputSource = | |
11 | Parser.lexarg | |
12 | ) : PARSE_GEN_PARSER = | |
13 | ||
14 | struct | |
15 | structure Header = Header | |
16 | val parse = fn file => | |
17 | let | |
18 | val in_str = TextIO.openIn file | |
19 | val source = Header.newSource(file,in_str,TextIO.stdOut) | |
20 | val error = fn (s : string,p:Header.pos,_) => | |
21 | Header.error source p s | |
22 | val stream = Parser.makeLexer (fn i => (TextIO.inputN(in_str,i))) | |
23 | source | |
24 | val (result,_) = (#line Header.pos := 1; #start Header.pos := 0; | |
25 | Header.text := nil; | |
26 | Parser.parse(15,stream,error,source)) | |
27 | in (TextIO.closeIn in_str; (result,source)) | |
28 | end | |
29 | end; |