(* parser.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. * * Parser glue. *) structure Parser : sig (* parse a file; return NONE if there are syntax errors *) val parseFile : (Error.err_stream * TextIO.instream) -> ParseTree.program option end = struct (* glue together the lexer and parser *) structure DiderotParser = DiderotParseFn(DiderotLex) (* error function for lexers *) fun lexErr errStrm (pos, msg) = Error.errorAt(errStrm, (pos, pos), msg) (* error function for parsers *) val parseErr = Error.parseError DiderotTokens.toString (* parse a file, returning a parse tree *) fun parseFile (errStrm, file) = let fun get () = TextIO.input file val lexer = DiderotLex.lex (Error.sourceMap errStrm) (lexErr errStrm) in case DiderotParser.parse lexer (DiderotLex.streamify get) of (SOME pt, _, []) => (TextIO.closeIn file; SOME pt) | (_, _, errs) => ( TextIO.closeIn file; List.app (parseErr errStrm) errs; NONE) (* end case *) end end
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: xtIO.closeIn file; List.app (parseErr errStrm) errs; NONE) (* end case *) end end