tests.java.org.python.antlr.PythonPartialTester Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jython-standalone Show documentation
Show all versions of jython-standalone Show documentation
Jython is an implementation of the high-level, dynamic, object-oriented
language Python written in 100% Pure Java, and seamlessly integrated with
the Java platform. It thus allows you to run Python on any Java platform.
package org.python.antlr;
import org.antlr.runtime.ANTLRFileStream;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.Token;
/**
* A walker producing a PythonTree
AST.
*/
public class PythonPartialTester {
public void parse(String[] args) throws Exception {
try {
PythonTree result = null;
CharStream input = new ANTLRFileStream(args[0]);
PythonPartialLexer lexer = new PythonPartialLexer(input);
CommonTokenStream tokens = new CommonTokenStream(lexer);
PythonTokenSource indentedSource = new PythonTokenSource(tokens, "");
tokens = new CommonTokenStream(indentedSource);
PythonPartialParser parser = new PythonPartialParser(tokens);
parser.single_input();
System.out.println("SUCCEED");
} catch (ParseException e) {
System.out.println("FAIL:" + e);
}
}
public static void main(String[] args) throws Exception {
PythonPartialTester p = new PythonPartialTester();
p.parse(args);
}
}