01: /**
02: * Copyright 2007 Jens Dietrich Licensed under the Apache License, Version 2.0 (the "License");
03: * you may not use this file except in compliance with the License.
04: * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
05: * Unless required by applicable law or agreed to in writing, software distributed under the
06: * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
07: * either express or implied. See the License for the specific language governing permissions
08: * and limitations under the License.
09: */package test.nz.org.take.compiler.scenario12;
10:
11: import org.apache.log4j.BasicConfigurator;
12: import nz.org.take.KnowledgeBase;
13: import nz.org.take.compiler.reference.DefaultCompiler;
14: import nz.org.take.compiler.util.jalopy.JalopyCodeFormatter;
15: import nz.org.take.nscript.ScriptException;
16: import nz.org.take.nscript.ScriptKnowledgeSource;
17:
18: /**
19: * Script to generate the interface for the test kb.
20: * @see KBFactory
21: * @author <a href="http://www-ist.massey.ac.nz/JBDietrich/">Jens Dietrich</a>
22: */
23:
24: public class GenerateInterfaces {
25:
26: /**
27: * Generate the interface for the example.
28: * @param args
29: */
30: public static void main(String[] args) throws Exception {
31: BasicConfigurator.configure();
32: nz.org.take.compiler.Compiler compiler = new DefaultCompiler();
33: compiler.add(new JalopyCodeFormatter());
34:
35: // generate kb
36: KnowledgeBase kb = null;
37: try {
38: ScriptKnowledgeSource KSrc = new ScriptKnowledgeSource(
39: Tests.class
40: .getResourceAsStream("/test/nz/org/take/compiler/scenario12/rules12.take"));
41: kb = KSrc.getKnowledgeBase();
42: } catch (ScriptException e) {
43: e.printStackTrace();
44: }
45: compiler
46: .setPackageName("test.nz.org.take.compiler.scenario12.generated");
47: compiler.setClassName("KB");
48: compiler.compileInterface(kb);
49:
50: }
51: }
|