1(*
2 * Copyright 2014, NICTA
3 *
4 * This software may be distributed and modified according to the terms of
5 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
6 * See "LICENSE_BSD2.txt" for details.
7 *
8 * @TAG(NICTA_BSD)
9 *)
10val _ = PolyML.Compiler.prompt1:="";
11val _ = PolyML.Compiler.prompt2:="";
12val _ = PolyML.print_depth 0;
13val dir = valOf (OS.Process.getEnv "STP_PFX")
14
15infix |>
16fun x |> f = f x
17
18fun readmlb fname = let
19  val istr = TextIO.openIn fname
20  fun recurse () =
21      case TextIO.inputLine istr of
22        NONE => ()
23      | SOME s => let
24          open Substring
25          val s = s |> full |> dropr Char.isSpace |> dropl Char.isSpace |> string
26          val lower_s = CharVector.map Char.toLower s
27        in
28          if not (String.isPrefix "mlton" lower_s) andalso
29             (String.isSuffix "ml" lower_s orelse String.isSuffix "sig" lower_s)
30          then
31            use (dir ^ "/" ^ s)
32          else ();
33          recurse ()
34        end
35in
36  recurse ()
37end
38
39structure MLton =
40struct
41  val eq = PolyML.pointerEq
42end;
43
44val _ = app (fn s => use (dir ^ "/../" ^ s))
45        ["tools/mlyacc/mlyacclib/MLY_base-sig.ML",
46         "tools/mlyacc/mlyacclib/MLY_join.ML",
47         "tools/mlyacc/mlyacclib/MLY_lrtable.ML",
48         "tools/mlyacc/mlyacclib/MLY_stream.ML",
49         "tools/mlyacc/mlyacclib/MLY_parser2.ML"]
50
51val _ = readmlb (dir ^ "/tokenizer.mlb");
52
53
54fun main() = Main.doit (CommandLine.arguments())
55
56val _ = PolyML.shareCommonData main;
57val _ = PolyML.export(dir ^ "/tokenizer", main);
58