Search in sources :

Example 56 with ANTLRStringStream

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);
}
Also used : ANTLRStringStream(org.antlr.runtime.ANTLRStringStream) CommonTokenStream(org.antlr.runtime.CommonTokenStream) JavaParser(org.drools.compiler.rule.builder.dialect.java.parser.JavaParser) CommonTokenStream(org.antlr.runtime.CommonTokenStream) TokenStream(org.antlr.runtime.TokenStream) JavaLexer(org.drools.compiler.rule.builder.dialect.java.parser.JavaLexer) CharStream(org.antlr.runtime.CharStream)

Example 57 with ANTLRStringStream

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);
}
Also used : ANTLRStringStream(org.antlr.runtime.ANTLRStringStream) Test(org.junit.Test)

Example 58 with ANTLRStringStream

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);
}
Also used : ANTLRStringStream(org.antlr.runtime.ANTLRStringStream) Test(org.junit.Test)

Example 59 with ANTLRStringStream

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);
}
Also used : ANTLRStringStream(org.antlr.runtime.ANTLRStringStream) Test(org.junit.Test)

Example 60 with ANTLRStringStream

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);
}
Also used : ANTLRStringStream(org.antlr.runtime.ANTLRStringStream) Test(org.junit.Test)

Aggregations

ANTLRStringStream (org.antlr.runtime.ANTLRStringStream)60 CommonTokenStream (org.antlr.runtime.CommonTokenStream)36 Test (org.junit.Test)20 CommonToken (org.antlr.runtime.CommonToken)15 Token (org.antlr.runtime.Token)13 CharStream (org.antlr.runtime.CharStream)11 Lexer (org.eclipse.xtext.parser.antlr.Lexer)10 RecognitionException (org.antlr.runtime.RecognitionException)9 InternalSimpleExpressionsTestLanguageLexer (org.eclipse.xtext.testlanguages.parser.antlr.internal.InternalSimpleExpressionsTestLanguageLexer)8 CommonTree (org.antlr.runtime.tree.CommonTree)6 ActionSplitter (org.antlr.v4.parse.ActionSplitter)6 TokenStream (org.antlr.runtime.TokenStream)5 InternalXtendLexer (org.eclipse.xtend.core.parser.antlr.internal.InternalXtendLexer)4 WindowingException (com.sap.hadoop.windowing.WindowingException)3 ExprLexer (org.apache.drill.common.expression.parser.ExprLexer)3 ExprParser (org.apache.drill.common.expression.parser.ExprParser)3 CeylonLexer (com.redhat.ceylon.compiler.typechecker.parser.CeylonLexer)2 CeylonParser (com.redhat.ceylon.compiler.typechecker.parser.CeylonParser)2 LineMap (com.sun.tools.javac.util.Position.LineMap)2 File (java.io.File)2