use of org.antlr.runtime.ANTLRStringStream 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.ANTLRStringStream in project drools by kiegroup.
the class RuleParserTest method testChunkWithParensAndQuotedString.
@Test
public void testChunkWithParensAndQuotedString() throws Exception {
String input = "( fnord( \"cheese\" ) )";
createParser(new ANTLRStringStream(input));
String returnData = parser.chunk(DRL6Lexer.LEFT_PAREN, DRL6Lexer.RIGHT_PAREN, -1);
assertEquals("fnord( \"cheese\" )", returnData);
}
use of org.antlr.runtime.ANTLRStringStream in project drools by kiegroup.
the class RuleParserTest method testChunkWithoutParens.
@Test
public void testChunkWithoutParens() throws Exception {
String input = "( foo )";
createParser(new ANTLRStringStream(input));
String returnData = parser.chunk(DRL6Lexer.LEFT_PAREN, DRL6Lexer.RIGHT_PAREN, -1);
assertEquals("foo", returnData);
}
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);
}
Aggregations