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 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 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 xtext-core by eclipse.
the class PartialContentAssistContextFactory method createContextsForLastCompleteNode.
@Override
protected void createContextsForLastCompleteNode(EObject previousModel, boolean strict) {
String currentNodePrefix = getPrefix(currentNode);
if (!Strings.isEmpty(currentNodePrefix) && !currentNode.getText().equals(currentNodePrefix)) {
lexer.setCharStream(new ANTLRStringStream(currentNodePrefix));
Token token = lexer.nextToken();
if (token == Token.EOF_TOKEN) {
return;
}
while (token != Token.EOF_TOKEN) {
if (isErrorToken(token)) {
return;
}
token = lexer.nextToken();
}
}
String prefix = "";
Collection<FollowElement> followElements = parseFollowElements(completionOffset, strict);
doCreateContexts(lastCompleteNode, currentNode, prefix, previousModel, followElements);
}
use of org.antlr.runtime.ANTLRStringStream in project xtext-core by eclipse.
the class AbstractLexerBasedConverter method getTokenSource.
protected TokenSource getTokenSource(String escapedValue) {
Lexer result = getLexer();
if (result == null)
return null;
result.setCharStream(new ANTLRStringStream(escapedValue));
return result;
}
Aggregations