use of net.taken.redsnake.parser.visitors.ASTBuilder in project redsnake by Taken0711.
the class TestUtils method parseProgram.
public static Program parseProgram(@NotNull String... s) {
StringBuilder str = new StringBuilder();
Arrays.stream(s).forEach(st -> str.append(st).append(System.lineSeparator()));
CharStream inputStream = CharStreams.fromString(str.toString());
RedsnakeLexer redsnakeLexer = new RedsnakeLexer(inputStream);
TokenStream commonTokenStream = new CommonTokenStream(redsnakeLexer);
RedsnakeParser parser = new RedsnakeParser(commonTokenStream);
ParseTree t = parser.program();
return (Program) new ASTBuilder().visit(t);
}
use of net.taken.redsnake.parser.visitors.ASTBuilder in project redsnake by Taken0711.
the class TestUtils method parseStatement.
public static Statement parseStatement(@NotNull String s) {
CharStream inputStream = CharStreams.fromString(s);
RedsnakeLexer redsnakeLexer = new RedsnakeLexer(inputStream);
TokenStream commonTokenStream = new CommonTokenStream(redsnakeLexer);
RedsnakeParser parser = new RedsnakeParser(commonTokenStream);
ParseTree t = parser.expression();
return (Expression) new ASTBuilder().visit(t);
}
Aggregations