Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/ckit/src/parser/parser.sml
ViewVC logotype

Annotation of /sml/trunk/ckit/src/parser/parser.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 597 - (view) (download)

1 : dbm 597 (* Copyright (c) 1998 by Lucent Technologies *)
2 :    
3 :     structure Parser : PARSER =
4 :     struct
5 :    
6 :     (* instantiate parser structures *)
7 :     structure LrVals = LrValsFun(structure Token = LrParser.Token)
8 :    
9 :     structure TokTable = TokenTable(structure Tokens = LrVals.Tokens)
10 :    
11 :     structure CLex = CLexFun(structure Tokens = LrVals.Tokens
12 :     structure TokTable = TokTable)
13 :    
14 :     structure P = JoinWithArg(structure ParserData = LrVals.ParserData
15 :     structure Lex = CLex
16 :     structure LrParser = LrParser)
17 :    
18 :     fun parseFile errState f =
19 :     let val _ = TypeDefs.reset()
20 :    
21 :     val sourceMap = SourceMap.newmap{srcFile=f}
22 :    
23 :     fun lexErr (p1, p2, msg) =
24 :     Error.error (errState, SourceMap.location sourceMap (p1, p2), msg)
25 :     fun lexWarn (p1, p2, msg) =
26 :     Error.warning (errState, SourceMap.location sourceMap (p1, p2), msg)
27 :     fun parseErr (msg, p1, p2) =
28 :     Error.error (errState, SourceMap.location sourceMap (p1, p2), msg)
29 :    
30 :     fun inputc instrm i = TextIO.inputN(instrm,i)
31 :    
32 :     val lexArg = {comLevel = ref 0,
33 :     sourceMap = sourceMap,
34 :     charlist = ref ([] : string list),
35 :     stringstart = ref 0,
36 :     errWarn = {err=lexErr, warn = lexWarn}
37 :     }
38 :     val instrm = TextIO.openIn f
39 :     val lookahead = 15
40 :    
41 :     val lexer = LrParser.Stream.streamify (CLex.makeLexer (inputc instrm) lexArg)
42 :     val (res,_) = P.parse(lookahead, lexer, parseErr, sourceMap)
43 :     val _ = TextIO.closeIn instrm
44 :     in res
45 :     end
46 :     handle P.ParseError =>
47 :     (TextIO.output(Error.errStream errState,"ParseError raised\n");
48 :     [])
49 :    
50 :     end (* structure Parser *)

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0