01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //This file is part of KeY - Integrated Deductive Software Design
09: //Copyright (C) 2001-2003 Universitaet Karlsruhe, Germany
10: // and Chalmers University of Technology, Sweden
11: //
12: //The KeY system is protected by the GNU General Public License.
13: //See LICENSE.TXT for details.
14: //
15:
16: package de.uka.ilkd.key.rule.export;
17:
18: import java.io.File;
19:
20: import de.uka.ilkd.key.gui.Main;
21: import de.uka.ilkd.key.proof.init.ProofInputException;
22: import de.uka.ilkd.key.rule.export.html.HTMLTacletExporter;
23:
24: public class TacletExporter {
25:
26: /** Option name for setting output directory. */
27: private static String OPT_OUTPUTDIR = "-key-html-dir";
28: /** Option name for omitting standard rules. */
29: private static String OPT_NOSTANDARDRULES = "-key-no-standard-rules";
30:
31: private String outputDir;
32:
33: public void exportAll(TacletLoader l) {
34: RuleExportModel model = new RuleExportModel();
35: l.addAllLoadedRules(model);
36: model.analyze();
37:
38: HTMLTacletExporter exp = new HTMLTacletExporter();
39:
40: exp.setModel(model);
41:
42: if (outputDir == null) {
43: outputDir = "html" + File.separatorChar;
44: } else if (outputDir.charAt(outputDir.length() - 1) != File.separatorChar) {
45: outputDir = outputDir + File.separatorChar;
46: }
47:
48: exp.run(outputDir);
49: }
50:
51: public static void main(String[] args) {
52: Main.configureLogger();
53:
54: final TacletLoader loader = new TacletLoader();
55: final TacletExporter exporter = new TacletExporter();
56:
57: int n = 0;
58:
59: for (; n < args.length && args[n].startsWith("-"); n++) {
60: final String argn = args[n];
61: if (argn.equals(OPT_NOSTANDARDRULES)) {
62: loader.setLoadStandardRules(false);
63: } else if (argn.equals(OPT_OUTPUTDIR)) {
64: n++;
65: if (n < args.length) {
66: exporter.outputDir = args[n];
67: } else {
68: System.err
69: .println("Expected output directory after "
70: + OPT_OUTPUTDIR);
71: }
72: }
73: }
74:
75: if (loader.getLoadStandardRules()) {
76: try {
77: loader.loadFile("standardRules.key");
78: } catch (ProofInputException e) {
79: System.err
80: .println("Loading of standard rules failed:\n"
81: + e);
82: return;
83: }
84: }
85:
86: exporter.exportAll(loader);
87: }
88: }
|