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

SCM Repository

[smlnj] View of /smlnj-lib/branches/rt-transition/HTML/test-parser.sml
ViewVC logotype

View of /smlnj-lib/branches/rt-transition/HTML/test-parser.sml

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2 - (download) (annotate)
Sat Oct 4 23:33:09 1997 UTC (23 years, 2 months ago) by monnier
Original Path: sml/trunk/src/smlnj-lib/HTML/test-parser.sml
File size: 1823 byte(s)
Initial revision
(* test-parser.sml
 * COPYRIGHT (c) 1996 AT&T REsearch.
 * This is a simple test driver for the HTML parser.

structure Main : sig

    val doit : string -> HTML.html option
    val main : (string * string list) -> OS.Process.status

  end = struct

    structure Err =
	type context = {file : string option, line : int}

	structure F = Format

	fun prf ({file, line}, fmt, args) = (
	      case file
	       of NONE => TextIO.output (
		    F.format "line %3d: " [F.INT line])
		| (SOME fname) => TextIO.output (
		    F.format "%s[%d]: " [F.STR fname, F.INT line])
	      (* end case *);
	      TextIO.output(TextIO.stdErr, F.format fmt args);
	      TextIO.output1(TextIO.stdErr, #"\n"))

	fun badStartTag ctx tagName =
	      prf (ctx, "unrecognized start tag \"%s\"",[F.STR tagName])

	fun badEndTag ctx tagName =
	      prf (ctx, "unrecognized end tag \"%s\"",[F.STR tagName])

	fun badAttrVal ctx (attrName, attrVal) =
	      prf (ctx, "bad value \"%s\" for attribute \"%s\"",
		[F.STR attrVal, F.STR attrName])

	fun lexError ctx msg = prf (ctx, "%s", [F.STR msg])

	fun syntaxError ctx msg = prf (ctx, "%s", [F.STR msg])

	fun missingAttrVal ctx attrName =
	      prf (ctx, "missing value for \"%s\" attribute", [F.STR attrName])

	fun missingAttr ctx attrName =
	      prf (ctx, "missing \"%s\" attribute", [F.STR attrName])

	fun unknownAttr ctx attrName =
	      prf (ctx, "unknown attribute \"%s\"", [F.STR attrName])

	fun unquotedAttrVal ctx attrName =
	      prf (ctx, "attribute value for \"%s\" should be quoted",
		[F.STR attrName])


    structure P = HTMLParserFn(Err);

    fun doit fname = SOME(P.parseFile fname) (* handle _ => NONE *)

    fun main (_, files) = (List.app (ignore o doit) files; OS.Process.success)


ViewVC Help
Powered by ViewVC 1.0.0