use of org.antlr.runtime.ANTLRStringStream in project drools by kiegroup.
the class RuleParserTest method testChunkWithParens.
@Test
public void testChunkWithParens() throws Exception {
String input = "(fnord())";
createParser(new ANTLRStringStream(input));
String returnData = parser.chunk(DRL6Lexer.LEFT_PAREN, DRL6Lexer.RIGHT_PAREN, -1);
assertEquals("fnord()", returnData);
}
use of org.antlr.runtime.ANTLRStringStream in project drools by kiegroup.
the class RuleParserTest method testChunkWithRandomCharac5ters.
@Test
public void testChunkWithRandomCharac5ters() throws Exception {
String input = "( %*9dkj)";
createParser(new ANTLRStringStream(input));
String returnData = parser.chunk(DRL6Lexer.LEFT_PAREN, DRL6Lexer.RIGHT_PAREN, -1);
assertEquals("%*9dkj", returnData);
}
use of org.antlr.runtime.ANTLRStringStream 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.ANTLRStringStream 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;
}
use of org.antlr.runtime.ANTLRStringStream in project drill by axbaretto.
the class TreeTest method parseExpression.
private LogicalExpression parseExpression(String expr) throws RecognitionException, IOException {
ExprLexer lexer = new ExprLexer(new ANTLRStringStream(expr));
CommonTokenStream tokens = new CommonTokenStream(lexer);
// tokens.fill();
// for(Token t : (List<Token>) tokens.getTokens()){
// System.out.println(t + "" + t.getType());
// }
// tokens.rewind();
ExprParser parser = new ExprParser(tokens);
parse_return ret = parser.parse();
return ret.e;
}
Aggregations