use of org.antlr.runtime.CommonTokenStream in project drools by kiegroup.
the class DSLTokenizedMappingFile method buildFileMappingWalker.
private DSLMapWalker buildFileMappingWalker(final List<ParserError> errors, CharStream stream) throws RecognitionException {
DSLMapLexer lexer = new DSLMapLexer(stream);
CommonTokenStream tokens = new CommonTokenStream();
tokens.setTokenSource(lexer);
DSLMapParser parser = new DSLMapParser(tokens);
DSLMapParser.mapping_file_return example = parser.mapping_file();
CommonTree tree = (CommonTree) example.getTree();
// logger.info(tree.toStringTree());
CommonTreeNodeStream nodes = new CommonTreeNodeStream(tree);
DSLMapWalker walker = new DSLMapWalker(nodes);
errors.addAll(lexer.getErrors());
errors.addAll(parser.getErrors());
return walker;
}
use of org.antlr.runtime.CommonTokenStream in project drools by kiegroup.
the class JavaExprAnalyzer method parse.
private JavaParser parse(final String expr) {
final CharStream charStream = new ANTLRStringStream(expr);
final JavaLexer lexer = new JavaLexer(charStream);
final TokenStream tokenStream = new CommonTokenStream(lexer);
return new JavaParser(tokenStream);
}
use of org.antlr.runtime.CommonTokenStream in project jwt by emweb.
the class CssParser method parseFile.
public StyleSheet parseFile(CharSequence stylesheetContents) {
Css21LexerExt lex = null;
Css21ParserExt parser = null;
try {
lex = new Css21LexerExt(new ANTLRFileStream(stylesheetContents.toString()));
CommonTokenStream tokens = new CommonTokenStream(lex);
parser = new Css21ParserExt(tokens);
currentStylesheet = new StyleSheetImpl();
parser.styleSheet();
lastError_ = lex.lastError_ + parser.lastError_;
return !lex.hasError_ && !parser.hasError_ ? currentStylesheet : null;
} catch (RecognitionException e) {
// e.printStackTrace();
lastError_ = lex.lastError_ + parser.lastError_;
return null;
} catch (IOException e) {
// e.printStackTrace();
lastError_ = "file" + stylesheetContents + "not found.";
return null;
}
}
use of org.antlr.runtime.CommonTokenStream in project jwt by emweb.
the class CssParser method parse.
public StyleSheet parse(CharSequence stylesheetContents) {
Css21LexerExt lex = new Css21LexerExt(new ANTLRStringStream(stylesheetContents.toString()));
CommonTokenStream tokens = new CommonTokenStream(lex);
Css21ParserExt parser = new Css21ParserExt(tokens);
currentStylesheet = new StyleSheetImpl();
try {
parser.styleSheet();
lastError_ = lex.lastError_ + parser.lastError_;
return !lex.hasError_ && !parser.hasError_ ? currentStylesheet : null;
} catch (RecognitionException e) {
e.printStackTrace();
lastError_ = lex.lastError_ + parser.lastError_;
return null;
}
}
use of org.antlr.runtime.CommonTokenStream in project drill by axbaretto.
the class TestEvaluationVisitor method getExpr.
private LogicalExpression getExpr(String expr) throws Exception {
ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
CommonTokenStream tokens = new CommonTokenStream(lexer);
ExprParser parser = new ExprParser(tokens);
parse_return ret = parser.parse();
return ret.e;
}
Aggregations