Package wyvern.tools.typedAST.interfaces

Examples of wyvern.tools.typedAST.interfaces.TypedAST


      System.exit(-1);
    }
   
    try {
      Reader reader = new FileReader(file);
      TypedAST res = (TypedAST) new Wyvern().parse(reader, filename);
      res.typecheck(Globals.getStandardEnv(), Optional.empty());
      res = new DSLTransformer().transform(res);
      Value finalV = res.evaluate(Globals.getStandardEnv());
      TreeWriter t = new TreeWriter();
      finalV.writeArgsToTree(t);
      System.out.println(t.getResult());
    } catch (IOException e) {
      System.err.println("Error reading file " + filename);
View Full Code Here


import java.util.Optional;

public class Compiler {
  public static TypedAST compileSources(String filename, List<String> sources) {
    try {
      TypedAST ast = (TypedAST) new Wyvern().parse(new StringReader(sources.get(0)), "test input");
      ast.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
      return ast;
    } catch (IOException | CopperParserException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    }
  }

  @Override
  public TypedAST parse(ParseBuffer input) throws IOException, CopperParserException {
    TypedAST quoted = (TypedAST) new WyvernQuote().parse(input.getSrcString()+"\n");
    return new Application(new ExternalFunction(arrow(unit, Util.javaToWyvType(TypedAST.class)), (env, arg) -> {
      TypedAST adapted = new ToastExecutor(env).transform(quoted);
      return Util.toWyvObj(adapted);
    }), UnitVal.getInstance(FileLocation.UNKNOWN), FileLocation.UNKNOWN);
  }
View Full Code Here

    @Override
    public TypedAST transform(TypedAST input) {
      if (input instanceof ToastExpression) {
        Value result = input.evaluate(evalEnv);
        TypedAST iExn = Util.toJavaClass((Obj)result, TypedAST.class);
        if (!(iExn instanceof Obj))
          return iExn;
        TypedAST equivExn = Util.toJavaClass((Obj)iExn, TypedAST.class);
        return equivExn;
      }
      return super.defaultTransformation(input);
    }
View Full Code Here

    // For test.. by Stanley
    //Path path = Paths.get(args[0]);
    //Files.lines(path).forEach(s -> System.out.println(s));
   
    try (FileInputStream fis = new FileInputStream(file)) {
      TypedAST res = (TypedAST)new Wyvern().parse(new InputStreamReader(fis), "test input");
      Type checkedType = res.typecheck(Globals.getStandardEnv(), Optional.empty());
      System.out.println("Result type: "+checkedType);
      res = new DSLTransformer().transform(res);
      Value finalV = res.evaluate(Globals.getStandardEnv());
      System.out.println("Result: "+finalV);
    }
  }
View Full Code Here

    return new String(new char[] {(char)charCode});
  }

  public static TypedAST splice(ParseBuffer buffer) {
    try {
      TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(buffer.getSrcString()), "inner");
      return new SpliceExn(res);
    } catch (IOException | CopperParserException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    }
  }

  public static TypedAST spliceUnsafe(String str) {
    try {
      TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(str), "inner");
      return new SpliceExn(res);
    } catch (IOException | CopperParserException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    }
  }

  public static TypedAST splice(ParseBuffer buffer, String filename) {
    try {
      TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(buffer.getSrcString()), "inner");
      return new SpliceExn(res);
    } catch (IOException | CopperParserException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    }
  }

  public static SpliceBindExn spliceBinding(ParseBuffer buffer, List<NameBinding> bindings) {
    try {
      TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(buffer.getSrcString()), "inner");
      return new SpliceBindExn(res, bindings);
    } catch (IOException | CopperParserException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    }
  }

  public static SpliceBindExn spliceBinding(ParseBuffer buffer, List<NameBinding> bindings, String filename) {
    try {
      TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(buffer.getSrcString()), filename);
      return new SpliceBindExn(res, bindings);
    } catch (IOException | CopperParserException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

TOP

Related Classes of wyvern.tools.typedAST.interfaces.TypedAST

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.