Skip to content

Commit

Permalink
Fixed some issues which were preventing Orchard from working properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkitchin committed Sep 10, 2009
1 parent 19cfb57 commit 10879f1
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion OrcJava/src/orc/BackendDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions OrcJava/src/orc/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package orc;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions OrcJava/src/orc/Orc.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions OrcJava/src/orc/ast/oil/type/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public abstract class Type {
public static orc.ast.xml.type.Type[] marshalAll(List<Type> 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) {
Expand Down
3 changes: 3 additions & 0 deletions OrcJava/src/orc/ast/xml/expression/Stop.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions OrcJava/src/orc/ast/xml/type/Bot.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import orc.env.Env;

public class Bot extends Type {

public Bot() {}

@Override
public orc.ast.oil.type.Type unmarshal() {
Expand Down
2 changes: 2 additions & 0 deletions OrcJava/src/orc/ast/xml/type/Top.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions OrcJava/src/orc/ast/xml/type/Type.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ public abstract class Type {
public abstract orc.ast.oil.type.Type unmarshal();

public static List<orc.ast.oil.type.Type> unmarshalAll(Type[] ts) {

if (ts == null) { return null; }

List<orc.ast.oil.type.Type> newts = new LinkedList<orc.ast.oil.type.Type>();
for (Type t : ts) {
newts.add(t.unmarshal());
Expand Down
1 change: 1 addition & 0 deletions OrcJava/src/orc/ast/xml/type/TypeVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class TypeVariable extends Type {
@XmlAttribute(required=false)
public String name;

public TypeVariable() {}
public TypeVariable(int index) {
this(index, null);
}
Expand Down
2 changes: 1 addition & 1 deletion OrcJava/test/orc/test/ExamplesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
3 changes: 1 addition & 2 deletions OrcJava/test/orc/test/OilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import java.io.File;
import java.io.IOException;
import java.io.StringReader;

import orc.Config;
import orc.Orc;
Expand All @@ -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;
Expand Down

0 comments on commit 10879f1

Please sign in to comment.