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/trunk/HTML4/html4-lex-test.sml
ViewVC logotype

View of /smlnj-lib/trunk/HTML4/html4-lex-test.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3962 - (download) (annotate)
Mon Sep 15 19:13:56 2014 UTC (4 years, 10 months ago) by jhr
File size: 1424 byte(s)
  Add copyright notices to HTML4 files.
(* html4-lex-test.sml
 *
 * COPYRIGHT (c) 2014 The Fellowship of SML/NJ (http://www.smlnj.org)
 * All rights reserved.
 *)

structure Test = struct

open HTML4Tokens

fun handle_tok tok = print ((tokToString tok) ^ "\n")

fun handle_toks (source_map, lex_stream) =
    let val (tok, span, lex_stream') = HTML4Lexer.lex source_map lex_stream
            handle ex =>
                   (print ("Exception at " ^ (Int.toString (HTML4Lexer.getPos
                                                                lex_stream)) ^
                           "\n"); raise ex)
    in
        handle_tok tok;
        (* XXX Getting some weird equality type complaint if I use the
        equality operator here... *)
        case tok of EOF => () | _ => handle_toks(source_map, lex_stream')
    end

fun handle_file file_name =
    let
        val source_map = AntlrStreamPos.mkSourcemap ()
        val in_strm = TextIO.openIn file_name
        val lex_strm = HTML4Lexer.streamifyInstream in_strm
        val _ = handle_toks(source_map, lex_strm)
            handle ex => (TextIO.closeIn in_strm;
                          raise ex)
    in
        TextIO.closeIn in_strm
    end

fun main (_, args) = (List.app handle_file args; OS.Process.success)

end

(* ______________________________________________________________________
   End of html4-lex-test.sml
   ______________________________________________________________________ *)

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