diff --git a/OrcJava/src/orc/BackendDemo.java b/OrcJava/src/orc/BackendDemo.java index 1774c3943..8b8f714d0 100644 --- a/OrcJava/src/orc/BackendDemo.java +++ b/OrcJava/src/orc/BackendDemo.java @@ -58,7 +58,7 @@ public static void main(final String[] args) throws CompilationException, IOExce final Config cfg = new Config(); cfg.processArgs(args); // compile the specified input stream to OIL - final Expression e = Orc.compile(cfg.getReader(), cfg); + final Expression e = Orc.compile(cfg); if (e == null) { return; } diff --git a/OrcJava/src/orc/Config.java b/OrcJava/src/orc/Config.java index f503c4595..2814fe06b 100644 --- a/OrcJava/src/orc/Config.java +++ b/OrcJava/src/orc/Config.java @@ -15,6 +15,7 @@ package orc; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -280,6 +281,12 @@ public void setInputFile(final File file) throws CmdLineException { } } + public void inputFromString(final String source) { + instream = new ByteArrayInputStream(source.getBytes()); + filename = "text"; + hasInputFile = true; + } + @Option(name = "-exceptions", usage = "Enable exceptions (experimental), which is disabled by default.") public void setExceptionsOn(final boolean exceptionsOn) { this.exceptionsOn = exceptionsOn; diff --git a/OrcJava/src/orc/Orc.java b/OrcJava/src/orc/Orc.java index 063d68329..5140f0c62 100644 --- a/OrcJava/src/orc/Orc.java +++ b/OrcJava/src/orc/Orc.java @@ -14,7 +14,6 @@ package orc; import java.io.IOException; -import java.io.Reader; import orc.ast.extended.declaration.Declaration; import orc.ast.extended.expression.Declare; @@ -75,7 +74,7 @@ public static void main(final String[] args) { engine.run(n); } - public static Expression compile(final Reader source, final Config cfg) throws IOException { + public static Expression compile(final Config cfg) throws IOException { final OrcCompiler compiler = new OrcCompiler(cfg); return compiler.call(); } diff --git a/OrcJava/src/orc/ast/oil/type/Type.java b/OrcJava/src/orc/ast/oil/type/Type.java index 98358c1e8..2ad734344 100755 --- a/OrcJava/src/orc/ast/oil/type/Type.java +++ b/OrcJava/src/orc/ast/oil/type/Type.java @@ -60,6 +60,7 @@ public abstract class Type { public static orc.ast.xml.type.Type[] marshalAll(List ts) { if (ts == null) { return null; } + orc.ast.xml.type.Type[] newts = new orc.ast.xml.type.Type[ts.size()]; int i = 0; for (Type t : ts) { diff --git a/OrcJava/src/orc/ast/xml/expression/Stop.java b/OrcJava/src/orc/ast/xml/expression/Stop.java index 88f65d83a..0e8675573 100644 --- a/OrcJava/src/orc/ast/xml/expression/Stop.java +++ b/OrcJava/src/orc/ast/xml/expression/Stop.java @@ -4,6 +4,9 @@ import orc.error.compiletime.CompilationException; public class Stop extends Expression { + + public Stop() {} + @Override public orc.ast.oil.expression.Expression unmarshal(Config config) throws CompilationException { return new orc.ast.oil.expression.Stop(); diff --git a/OrcJava/src/orc/ast/xml/type/Bot.java b/OrcJava/src/orc/ast/xml/type/Bot.java index 0b9277275..961a17766 100644 --- a/OrcJava/src/orc/ast/xml/type/Bot.java +++ b/OrcJava/src/orc/ast/xml/type/Bot.java @@ -3,6 +3,8 @@ import orc.env.Env; public class Bot extends Type { + + public Bot() {} @Override public orc.ast.oil.type.Type unmarshal() { diff --git a/OrcJava/src/orc/ast/xml/type/Top.java b/OrcJava/src/orc/ast/xml/type/Top.java index 4ae1a529e..c5a642010 100644 --- a/OrcJava/src/orc/ast/xml/type/Top.java +++ b/OrcJava/src/orc/ast/xml/type/Top.java @@ -4,6 +4,8 @@ public class Top extends Type { + public Top() {} + @Override public orc.ast.oil.type.Type unmarshal() { return orc.ast.oil.type.Type.TOP; diff --git a/OrcJava/src/orc/ast/xml/type/Type.java b/OrcJava/src/orc/ast/xml/type/Type.java index f208f5eca..b51cfa36e 100644 --- a/OrcJava/src/orc/ast/xml/type/Type.java +++ b/OrcJava/src/orc/ast/xml/type/Type.java @@ -20,6 +20,9 @@ public abstract class Type { public abstract orc.ast.oil.type.Type unmarshal(); public static List unmarshalAll(Type[] ts) { + + if (ts == null) { return null; } + List newts = new LinkedList(); for (Type t : ts) { newts.add(t.unmarshal()); diff --git a/OrcJava/src/orc/ast/xml/type/TypeVariable.java b/OrcJava/src/orc/ast/xml/type/TypeVariable.java index 67f7ee21b..a002b407e 100644 --- a/OrcJava/src/orc/ast/xml/type/TypeVariable.java +++ b/OrcJava/src/orc/ast/xml/type/TypeVariable.java @@ -15,6 +15,7 @@ public class TypeVariable extends Type { @XmlAttribute(required=false) public String name; + public TypeVariable() {} public TypeVariable(int index) { this(index, null); } diff --git a/OrcJava/test/orc/test/ExamplesTest.java b/OrcJava/test/orc/test/ExamplesTest.java index 8b1981b99..71e5d2f4b 100644 --- a/OrcJava/test/orc/test/ExamplesTest.java +++ b/OrcJava/test/orc/test/ExamplesTest.java @@ -112,7 +112,7 @@ public static void runOrcProgram(final Config config, final File file, final Lin config.setQuietChecking(true); final OrcEngine engine = new OrcEngine(config); - orc.ast.oil.expression.Expression expr = Orc.compile(config.getReader(), config); + orc.ast.oil.expression.Expression expr = Orc.compile(config); if (expr == null) { throw new CompilationException("Compilation to OIL failed"); } diff --git a/OrcJava/test/orc/test/OilTest.java b/OrcJava/test/orc/test/OilTest.java index 0f7d860f0..3b11e918c 100644 --- a/OrcJava/test/orc/test/OilTest.java +++ b/OrcJava/test/orc/test/OilTest.java @@ -15,7 +15,6 @@ import java.io.File; import java.io.IOException; -import java.io.StringReader; import orc.Config; import orc.Orc; @@ -30,7 +29,7 @@ public class OilTest { public void unmarshal() throws CompilationException, IOException, CmdLineException { final Config config = new Config(); config.setInputFile(new File("examples/strcat.orc")); //Must have a file in config. It can be bogus. :-) - final Oil oil1 = new Oil(Orc.compile(new StringReader("1"), config)); + final Oil oil1 = new Oil(Orc.compile(config)); final String xml = oil1.toXML(); System.out.println(xml); // TODO: verify the syntax of the XML;