1 /********************************************************************************
2 *
3 * Copyright (C) 2008 Fujitsu Services Ltd.
4 *
5 * Author: Nick Battle
6 *
7 * This file is part of VDMJ.
8 *
9 * VDMJ is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * VDMJ is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with VDMJ. If not, see <http://www.gnu.org/licenses/>.
21 *
22 ******************************************************************************/
23
24 package org.overturetool.vdmj;
25
26 import java.io.File;
27 import java.util.List;
28 import java.util.Vector;
29
30 import org.overturetool.vdmj.commands.CommandReader;
31 import org.overturetool.vdmj.commands.ModuleCommandReader;
32 import org.overturetool.vdmj.lex.Dialect;
33 import org.overturetool.vdmj.lex.LexTokenReader;
34 import org.overturetool.vdmj.modules.ModuleList;
35 import org.overturetool.vdmj.runtime.ModuleInterpreter;
36 import org.overturetool.vdmj.syntax.ModuleReader;
37 import org.overturetool.vdmj.typechecker.ModuleTypeChecker;
38 import org.overturetool.vdmj.typechecker.TypeChecker;
39
40
41 public class Minimal
42 {
43 public static void main(String[] args) throws Exception
44 {
45 File file = new File(args[0]);
46 LexTokenReader ltr = new LexTokenReader(file, Dialect.VDM_SL);
47 ModuleReader mr = new ModuleReader(ltr);
48 ModuleList modules = mr.readModules();
49
50 if (mr.getErrorCount() == 0)
51 {
52 TypeChecker tc = new ModuleTypeChecker(modules);
53 tc.typeCheck();
54
55 if (TypeChecker.getErrorCount() == 0)
56 {
57 ModuleInterpreter interpreter = new ModuleInterpreter(modules);
58 interpreter.init(null);
59 CommandReader reader = new ModuleCommandReader(interpreter, "$ ");
60 List<File> files = new Vector<File>();
61 files.add(file);
62 reader.run(files);
63 }
64 }
65 }
66 }