Examples of Wyvern


Examples of wyvern.tools.parsing.Wyvern

        "  class def create():C\n" +
        "    new\n" +
        "  def bar():Int\n" +
        "    9\n" +
        "C.create().bar()";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(9)");
  }
View Full Code Here

Examples of wyvern.tools.parsing.Wyvern

  public void parseSimpleType() throws IOException, CopperParserException {
    String input =
        "type T\n" +
        "  def bar():Int\n" +
        "5";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(5)");
  }
View Full Code Here

Examples of wyvern.tools.parsing.Wyvern

        "  class def create():T\n" +
        "    new\n" +
        "  def bar():Int\n" +
        "    9\n" +
        "C.create().bar()";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    Assert.assertEquals(res.typecheck(Globals.getStandardEnv(), Optional.empty()), Int.getInstance());
    Assert.assertEquals(res.evaluate(Globals.getStandardEnv()).toString(), "IntegerConstant(9)");
  }
View Full Code Here

Examples of wyvern.tools.parsing.Wyvern

  @Test
  public void testDSL1() throws IOException, CopperParserException {
    String input =
        "{ 1 { 2 } {3} 4 {5} {5 {6{{3}}}} }";
    DSLLit res = (DSLLit)new Wyvern().parse(new StringReader(input), "test input");
    Assert.assertEquals(" 1 { 2 } {3} 4 {5} {5 {6{{3}}}} ", res.getText().get());
  }
View Full Code Here

Examples of wyvern.tools.parsing.Wyvern

  public void testDSL2() throws IOException, CopperParserException {
    String input =
        "val test = ~\n" +
            "  hello\n" +
            "7\n";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    String parsed = ((DSLLit)((ValDeclaration) ((Sequence) res).getDeclIterator().iterator().next()).getDefinition()).getText().get();
    Assert.assertEquals("hello", parsed);
  }
View Full Code Here

Examples of wyvern.tools.parsing.Wyvern

        "val test:Int = ~\n" +
            "  hello\n" +
            "  world\n" +
            "    today\n" +
            "7\n";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    String parsed = ((DSLLit)((ValDeclaration) ((Sequence) res).getDeclIterator().iterator().next()).getDefinition()).getText().get();
    Assert.assertEquals("hello\nworld\n\ttoday", parsed);

  }
View Full Code Here

Examples of wyvern.tools.parsing.Wyvern

            "  hello\n" +
            "  world\n" +
            "    today\n" +
            "  today\n" +
            "7\n";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    String parsed = ((DSLLit)((ValDeclaration) ((Sequence) res).getDeclIterator().iterator().next()).getDefinition()).getText().get();
    Assert.assertEquals("hello\nworld\n\ttoday\ntoday", parsed);
  }
View Full Code Here

Examples of wyvern.tools.parsing.Wyvern

    String input =
        "val test = new\n" +
            "  val d = 4\n" +
            "  def x():Int = 7\n" +
            "7\n";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");

  }
View Full Code Here

Examples of wyvern.tools.parsing.Wyvern

    String input =
        "val test = (new.x())+9/3-3\n" +
            "  val d = 4\n" +
            "  def x():Int = 7\n" +
            "test\n";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    res.typecheck(Globals.getStandardEnv(), Optional.empty());
    Assert.assertEquals("IntegerConstant(7)",res.evaluate(Globals.getStandardEnv()).toString());
  }
View Full Code Here

Examples of wyvern.tools.parsing.Wyvern

        "val test = (new.d.k)+9/3-3\n" +
            "  val d = new\n" +
            "    val k = 19\n" +
            "  def x():Int = 7\n" +
            "test\n";
    TypedAST res = (TypedAST)new Wyvern().parse(new StringReader(input), "test input");
    res.typecheck(Globals.getStandardEnv(), Optional.empty());
    Assert.assertEquals("IntegerConstant(19)",res.evaluate(Globals.getStandardEnv()).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.