From 0a1e81c5811d640c00d5b5984d2254e0d8521743 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 19 Oct 2008 15:19:41 -0400 Subject: Building combined demo app --- src/demo.sml | 113 +++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 82 insertions(+), 31 deletions(-) (limited to 'src/demo.sml') diff --git a/src/demo.sml b/src/demo.sml index 015090e0..5bb11fa5 100644 --- a/src/demo.sml +++ b/src/demo.sml @@ -33,9 +33,6 @@ fun make {prefix, dirname} = file = "prose"} val inf = TextIO.openIn prose - val demo_urp = OS.Path.joinDirFile {dir = dirname, - file = "demo.urp"} - val outDir = OS.Path.concat (dirname, "out") val () = if OS.FileSys.access (outDir, []) then @@ -60,6 +57,17 @@ fun make {prefix, dirname} = val () = (TextIO.output (demosOut, "\n\n"); TextIO.output (demosOut, "
  • Intro
  • \n\n")) + val fname = OS.Path.joinDirFile {dir = dirname, + file = "demo.urs"} + val ursOut = TextIO.openOut fname + val () = (TextIO.output (ursOut, "val main : unit -> transaction page\n"); + TextIO.closeOut ursOut) + + val fname = OS.Path.joinDirFile {dir = dirname, + file = "demo.ur"} + val urOut = TextIO.openOut fname + val () = TextIO.output (urOut, "fun main () = return \n") + fun mergeWith f (o1, o2) = case (o1, o2) of (NONE, _) => o2 @@ -103,6 +111,12 @@ fun make {prefix, dirname} = TextIO.output (demosOut, name); TextIO.output (demosOut, "\n")) + val () = (TextIO.output (urOut, "
  • "); + TextIO.output (urOut, name); + TextIO.output (urOut, "
  • \n")) + val urp_file = OS.Path.joinDirFile {dir = dirname, file = urp} @@ -185,7 +199,8 @@ fun make {prefix, dirname} = fun readUrp' () = case TextIO.inputLine inf of - NONE => finished () + NONE => (finished (); + combined) | SOME line => if String.isSuffix ".urp\n" line then let @@ -216,7 +231,8 @@ fun make {prefix, dirname} = TextIO.closeOut out) in case TextIO.inputLine inf of - NONE => finished () + NONE => (finished (); + NONE) | SOME line => if String.isSuffix ".urp\n" line then let @@ -225,8 +241,8 @@ fun make {prefix, dirname} = in finished (); - readUrp (urpData, - out) + SOME (readUrp (urpData, + out)) end else (TextIO.output (out, line); @@ -274,36 +290,71 @@ fun make {prefix, dirname} = ignore (OS.Process.system cmd) end) in - case OS.Path.ext file of - SOME "urp" => - doit (fn (src, html) => - let - val inf = TextIO.openIn src - val out = TextIO.openOut html - - fun loop () = - case TextIO.inputLine inf of - NONE => () - | SOME line => (TextIO.output (out, line); - loop ()) - in - TextIO.output (out, "\n\n
    ");
    -                                             loop ();
    -                                             TextIO.output (out, "
    \n\n"); - - TextIO.closeIn inf; - TextIO.closeOut out - end) - | SOME "urs" => highlight () - | SOME "ur" => highlight () - | _ => (); + if OS.Path.base file = "demo" then + () + else case OS.Path.ext file of + SOME "urp" => + doit (fn (src, html) => + let + val inf = TextIO.openIn src + val out = TextIO.openOut html + + fun loop () = + case TextIO.inputLine inf of + NONE => () + | SOME line => (TextIO.output (out, line); + loop ()) + in + TextIO.output (out, "\n\n
    ");
    +                                                  loop ();
    +                                                  TextIO.output (out, "
    \n\n"); + + TextIO.closeIn inf; + TextIO.closeOut out + end) + | SOME "urs" => highlight () + | SOME "ur" => highlight () + | _ => (); loop () end in loop () end in - readIndex (); + case readIndex () of + NONE => raise Fail "No demo applications!" + | SOME combined => + let + val () = (TextIO.output (urOut, "
    \n"); + TextIO.closeOut urOut) + + val fname = OS.Path.joinDirFile {dir = dirname, + file = "demo.urp"} + val outf = TextIO.openOut fname + in + Option.app (fn db => (TextIO.output (outf, "database "); + TextIO.output (outf, db); + TextIO.output (outf, "\n"))) + (#database combined); + TextIO.output (outf, "sql demo.sql\n"); + TextIO.output (outf, "\n"); + + app (fn s => + let + val s = OS.Path.mkAbsolute {relativeTo = OS.FileSys.getDir (), + path = s} + in + TextIO.output (outf, s); + TextIO.output (outf, "\n") + end) + (#sources combined); + TextIO.output (outf, "\n"); + TextIO.output (outf, "demo\n"); + + TextIO.closeOut outf; + + Compiler.compile (OS.Path.base fname) + end; TextIO.output (demosOut, "\n\n"); TextIO.closeOut demosOut; -- cgit v1.2.3