Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import org.antlr.v4.runtime.CommonTokenStream;
- import org.antlr.v4.runtime.tree.ParseTree;
- import antlr.RobotLexer;
- import antlr.RobotParser;
- import org.antlr.v4.gui.TreeViewer;
- import org.antlr.v4.runtime.ANTLRInputStream;
- import org.antlr.v4.runtime.CharStream;
- @SuppressWarnings("deprecation")
- public class Main {
- public static void main(String[] args) {
- CharStream in = new ANTLRInputStream("move (3+2) + 11 * (3+4) off");
- RobotLexer lexer = new RobotLexer(in);
- CommonTokenStream tokens = new CommonTokenStream(lexer);
- RobotParser parser = new RobotParser(tokens);
- ParseTree tree = parser.eval();
- // TreeViewer viewr = new TreeViewer(Arrays.asList(
- // parser.getRuleNames()),tree);
- // viewr.open();
- new MyVisitor().visit(tree);
- // parser.eval();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement