1structure AssembleHolindexParser :> AssembleHolindexParser = 2struct 3 4 structure HolindexLrVals = 5 HolindexLrValsFun(structure Token = LrParser.Token) 6 7 structure HolindexLex = 8 HolindexLexFun(structure Tokens = HolindexLrVals.Tokens) 9 10 11 structure DiskFileParser = 12 Join(structure ParserData = HolindexLrVals.ParserData 13 structure Lex = HolindexLex 14 structure LrParser = LrParser) 15 16 17 fun print_parse_error s = 18 print ("Error: "^s^"\n"); 19 20 fun invoke lexstream = let 21 open PPBackEnd; 22 val error_count = ref 0; 23 fun print_error (s,(j:int,i:int),_) = 24 ((if (!error_count > 0) then () else print "\n"); 25 (error_count := !error_count + 1); 26 print_parse_error (" "^ 27 " line "^(Int.toString (i+1)) ^ ": " ^ s); 28 (if (!error_count > 15) then Feedback.fail() else ())); 29 30 val r = (#1 (DiskFileParser.parse(15,lexstream,print_error,()))) 31 handle HolindexLex.UserDeclarations.LexicalError (tok, j, i) => 32 let 33 val s = "lex error - ill formed token \""^tok^"\""; 34 val _ = print_error (s, (j, i), (j,i)); 35 in 36 Feedback.fail() 37 end; 38 in 39 (if (!error_count > 0) then Feedback.fail() else r) 40 end 41 42 fun raw_read_stream strm = let 43 val lexer = DiskFileParser.makeLexer (fn _ => Portable.input_line strm) 44 in 45 invoke lexer 46 end 47 48 fun raw_read_file fname = let 49 val strm = TextIO.openIn fname 50 in 51 raw_read_stream strm before TextIO.closeIn strm 52 end 53 54 val parse_hdf_file = raw_read_file; 55 56end; 57