comparison src/main.mlton.sml @ 1493:9cb923efea4d

Generated pretty-printed HTML for a simple tutorial source file
author Adam Chlipala <adam@chlipala.net>
date Fri, 15 Jul 2011 16:50:55 -0400
parents 79557535b843
children b5517f47b1f1
comparison
equal deleted inserted replaced
1492:175b6d52252d 1493:9cb923efea4d
1 (* Copyright (c) 2008-2010, Adam Chlipala 1 (* Copyright (c) 2008-2011, Adam Chlipala
2 * All rights reserved. 2 * All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
27 27
28 val timing = ref false 28 val timing = ref false
29 val tc = ref false 29 val tc = ref false
30 val sources = ref ([] : string list) 30 val sources = ref ([] : string list)
31 val demo = ref (NONE : (string * bool) option) 31 val demo = ref (NONE : (string * bool) option)
32 val tutorial = ref false
32 val css = ref false 33 val css = ref false
33 34
34 fun doArgs args = 35 fun doArgs args =
35 case args of 36 case args of
36 [] => () 37 [] => ()
40 | "-demo" :: prefix :: rest => 41 | "-demo" :: prefix :: rest =>
41 (demo := SOME (prefix, false); 42 (demo := SOME (prefix, false);
42 doArgs rest) 43 doArgs rest)
43 | "-guided-demo" :: prefix :: rest => 44 | "-guided-demo" :: prefix :: rest =>
44 (demo := SOME (prefix, true); 45 (demo := SOME (prefix, true);
46 doArgs rest)
47 | "-tutorial" :: rest =>
48 (tutorial := true;
45 doArgs rest) 49 doArgs rest)
46 | "-protocol" :: name :: rest => 50 | "-protocol" :: name :: rest =>
47 (Settings.setProtocol name; 51 (Settings.setProtocol name;
48 doArgs rest) 52 doArgs rest)
49 | "-prefix" :: prefix :: rest => 53 | "-prefix" :: prefix :: rest =>
116 case !sources of 120 case !sources of
117 [file] => file 121 [file] => file
118 | _ => raise Fail "Zero or multiple job files specified" 122 | _ => raise Fail "Zero or multiple job files specified"
119 123
120 val () = 124 val () =
121 case (!css, !demo) of 125 case (!css, !demo, !tutorial) of
122 (true, _) => 126 (true, _, _) =>
123 (case Compiler.run Compiler.toCss job of 127 (case Compiler.run Compiler.toCss job of
124 NONE => OS.Process.exit OS.Process.failure 128 NONE => OS.Process.exit OS.Process.failure
125 | SOME {Overall = ov, Classes = cl} => 129 | SOME {Overall = ov, Classes = cl} =>
126 (app (print o Css.inheritableToString) ov; 130 (app (print o Css.inheritableToString) ov;
127 print "\n"; 131 print "\n";
129 (print x; 133 (print x;
130 print " "; 134 print " ";
131 app (print o Css.inheritableToString) ins; 135 app (print o Css.inheritableToString) ins;
132 app (print o Css.othersToString) ots; 136 app (print o Css.othersToString) ots;
133 print "\n")) cl)) 137 print "\n")) cl))
134 | (_, SOME (prefix, guided)) => 138 | (_, SOME (prefix, guided), _) =>
135 Demo.make {prefix = prefix, dirname = job, guided = guided} 139 Demo.make {prefix = prefix, dirname = job, guided = guided}
140 | (_, _, true) => Tutorial.make job
136 | _ => 141 | _ =>
137 if !tc then 142 if !tc then
138 (Compiler.check Compiler.toElaborate job; 143 (Compiler.check Compiler.toElaborate job;
139 if ErrorMsg.anyErrors () then 144 if ErrorMsg.anyErrors () then
140 OS.Process.exit OS.Process.failure 145 OS.Process.exit OS.Process.failure