Examples of DSLTransformer


Examples of wyvern.tools.parsing.transformers.DSLTransformer

   
    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) {
View Full Code Here

Examples of wyvern.tools.parsing.transformers.DSLTransformer

   
    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

Examples of wyvern.tools.parsing.transformers.DSLTransformer

        res = (TypedAST)new Wyvern().parse(source, filename);
      } catch (IOException | CopperParserException e) {
        throw new RuntimeException(e);
      }
      res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
      res = new DSLTransformer().transform(res);
    }
View Full Code Here

Examples of wyvern.tools.parsing.transformers.DSLTransformer

      }
    };

    TypeDeclaration.attrEvalEnv = Environment.getEmptyEnvironment().extend(new ValueBinding("myNumMetadata", Util.toWyvObj(inner)));
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv().extend(new NameBindingImpl("myNumMetadata", metaType)), Optional.empty()), Int.getInstance());
    res = new DSLTransformer().transform(res);
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv().extend(new ValueBinding("myNumMetadata", Util.toWyvObj(inner)))).toString(), "IntegerConstant(5)");
  }
View Full Code Here

Examples of wyvern.tools.parsing.transformers.DSLTransformer

            "n.getValue()";

    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");

    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    res = new DSLTransformer().transform(res);
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(5)");
  }
View Full Code Here

Examples of wyvern.tools.parsing.transformers.DSLTransformer

    WyvernResolver.clearFiles();
    WyvernResolver.addFile("in1", input);
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(in2), "test input");

    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    res = new DSLTransformer().transform(res);
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(5)");
  }
View Full Code Here

Examples of wyvern.tools.parsing.transformers.DSLTransformer

      }
    };

    TypeDeclaration.attrEvalEnv = Environment.getEmptyEnvironment().extend(new ValueBinding("myNumMetadata", Util.toWyvObj(inner))).extend(new TypeBinding("HasParser", metaType));
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv().extend(new NameBindingImpl("myNumMetadata", metaType)), Optional.empty()), Int.getInstance());
    res = new DSLTransformer().transform(res);
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv().extend(new ValueBinding("myNumMetadata", Util.toWyvObj(inner)))).toString(), "IntegerConstant(5)");
  }
View Full Code Here

Examples of wyvern.tools.parsing.transformers.DSLTransformer

    WyvernResolver.addFile("parser", parser);
    WyvernResolver.addFile("typer", typer);

    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(user), "test input");
    Type result = res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    res = new DSLTransformer().transform(res);
    Assert.assertEquals("Int", result.toString());

    Value out = res.evaluate(Globals.getStandardEnv());
    Assert.assertEquals("IntegerConstant(13)", out.toString());
  }
View Full Code Here

Examples of wyvern.tools.parsing.transformers.DSLTransformer

    WyvernResolver.addFile("parser", parser);
    WyvernResolver.addFile("supplier", supplier);

    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(client), "test input");
    Type result = res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty());
    res = new DSLTransformer().transform(res);
    Value finalV = res.evaluate(Globals.getStandardEnv());
  }
View Full Code Here

Examples of wyvern.tools.parsing.transformers.DSLTransformer

  @Override
  public void execute() throws IOException, CopperParserException {
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(code+"\n"), "test input");
    Assert.assertEquals(expectedType, res.typecheck(Globals.getStandardEnv(), Optional.<Type>empty()).toString());
    res = new DSLTransformer().transform(res);
    Value finalV = res.evaluate(Globals.getStandardEnv());
    Assert.assertEquals(expectedValue, finalV.toString());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.