structure Parse :> PARSE =
struct
- structure L1LrVals = L1LrValsFn (structure Token = LrParser.Token)
- structure L1Lex = L1LexFn (structure Tokens = L1LrVals.Tokens)
- structure L1Parse = Join (structure ParserData = L1LrVals.ParserData
- structure Lex = L1Lex
+ structure L2LrVals = L2LrValsFn (structure Token = LrParser.Token)
+ structure L2Lex = L2LexFn (structure Tokens = L2LrVals.Tokens)
+ structure L2Parse = Join (structure ParserData = L2LrVals.ParserData
+ structure Lex = L2Lex
structure LrParser = LrParser)
(* Main parsing function *)
val _ = ParseState.setfile filename (* start at position 0 in filename *)
fun parseerror (s, p1, p2) = ErrorMsg.error (ParseState.ext (p1,p2)) s
val lexer = LrParser.Stream.streamify
- (L1Lex.makeLexer (fn _ => TextIO.input instream))
+ (L2Lex.makeLexer (fn _ => TextIO.input instream))
(* 0 = no error correction, 15 = reasonable lookahead for correction *)
- val (absyn, _) = L1Parse.parse(0, lexer, parseerror, ())
+ val (absyn, _) = L2Parse.parse(0, lexer, parseerror, ())
val _ = if !ErrorMsg.anyErrors
then raise ErrorMsg.Error
else ()
in
absyn
end)
- handle L1Lex.LexError => ( ErrorMsg.error NONE "lexer error" ;
- raise ErrorMsg.Error )
+ handle Fail s => ( ErrorMsg.error NONE ("lexer error: "^s) ;
+ raise ErrorMsg.Error )
| LrParser.ParseError => raise ErrorMsg.Error (* always preceded by msg *)
| e as IO.Io _ => ( ErrorMsg.error NONE (exnMessage e);
raise ErrorMsg.Error )