/** Parse data or input file and initialize the parse tree. */
private void parseInput() {
if (data == null)
loadInputFile();
if (data == null)
throw new IllegalArgumentException("Unable to load input file or data is missing.");
ANTLRInputStream input = new ANTLRInputStream(data);
SaltLexer lexer = new SaltLexer(input);
lexer.addErrorListener(new BaseErrorListener() {
@Override
public void syntaxError(Recognizer<?, ?> arg0, Object arg1, int arg2,
int arg3, String arg4, RecognitionException arg5) {
throw new RuntimeException(arg5);
}
});
CommonTokenStream tokens = new CommonTokenStream(lexer);
SaltParser parser = new SaltParser(tokens);
tree = parser.document();
if (parser.getNumberOfSyntaxErrors() > 0) {
System.out.println("Syntax error in file " + inputFile);
return;
}
}
SaltProcessor.java 文件源码
java
阅读 16
收藏 0
点赞 0
评论 0
项目:salt9000
作者:
评论列表
文章目录