use of net.taken.redsnake.parser.RedsnakeParser in project redsnake by Taken0711.
the class Redsnake method buildAST.
public Statement buildAST(CharStream inputStream) {
RedsnakeLexer redsnakeLexer = new RedsnakeLexer(inputStream);
TokenStream commonTokenStream = new CommonTokenStream(redsnakeLexer);
RedsnakeParser parser = new RedsnakeParser(commonTokenStream);
ParseTree t = parser.statement();
return (Statement) astBuilder.visit(t);
}
use of net.taken.redsnake.parser.RedsnakeParser 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.RedsnakeParser 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