Java Code Examples for org.eclipse.xtext.parser.antlr.Lexer#setCharStream()
The following examples show how to use
org.eclipse.xtext.parser.antlr.Lexer#setCharStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TokenSequencePreservingPartialParsingHelper.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected boolean isSameTokenSequence(String originalText, String newText, int expectedLength) { Lexer originalLexer = lexerProvider.get(); Lexer newLexer = lexerProvider.get(); originalLexer.setCharStream(new ANTLRStringStream(originalText)); newLexer.setCharStream(new ANTLRStringStream(newText)); return isSameTokenSequence(originalLexer, newLexer, expectedLength); }
Example 2
Source File: AbstractTemplateProposalConflictHelper.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected void initTokenSource(String text, TokenSource tokenSource, ContentAssistContext context) { EObject currentModel = context.getLastCompleteNode().getSemanticElement(); Variable variable = currentModel != null ? EcoreUtil2.getContainerOfType(currentModel, Variable.class) : null; TemplateBody body = currentModel != null ? EcoreUtil2.getContainerOfType(currentModel, TemplateBody.class) : null; Lexer lexer = (Lexer) tokenSource; CharStream stream = new ANTLRStringStream(text); lexer.setCharStream(stream); initLexer(lexer, body != null, variable != null); }
Example 3
Source File: DocumentTokenSource.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @deprecated use {@link #createTokenSource(String)} instead. */ @Deprecated protected Lexer createLexer(String string) { Lexer l = lexer.get(); l.setCharStream(new ANTLRStringStream(string)); return l; }
Example 4
Source File: LexingTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected void assertLexing(String input, Pair<String,String>... expectedTokens) { Lexer lexer = new InternalXtendLexer(null); CharStream stream = new ANTLRStringStream(input); lexer.setCharStream(stream); XtextTokenStream tokenStream = new XtextTokenStream(lexer, tokenDefProvider); List<?> tokens = tokenStream.getTokens(); assertEquals(input + " / " + tokens, expectedTokens.length, tokens.size()); for(int i = 0;i < tokens.size(); i++) { Token token = (Token) tokens.get(i); assertEquals(token.toString(), expectedTokens[i].getFirst(), token.getText()); final String expected = expectedTokens[i].getSecond(); String actual = tokenDefProvider.getTokenDefMap().get(token.getType()); assertEquals("expected "+expected+" but was "+actual, expected, actual); } }
Example 5
Source File: AbstractLexerBasedConverter.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected TokenSource getTokenSource(String escapedValue) { Lexer result = getLexer(); if (result == null) return null; result.setCharStream(new ANTLRStringStream(escapedValue)); return result; }
Example 6
Source File: HighlightingParser.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * Create a new lexer for the given input. */ protected TokenSource createLexer(CharStream stream) { Lexer lexer = lexerProvider.get(); lexer.setCharStream(stream); return lexer; }
Example 7
Source File: AntlrProposalConflictHelper.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected void initTokenSource(String text, TokenSource tokenSource, ContentAssistContext context) { Lexer lexer = (Lexer) tokenSource; CharStream stream = new ANTLRStringStream(text); lexer.setCharStream(stream); }
Example 8
Source File: DocumentTokenSource.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
/** * @since 2.4 */ protected TokenSource createTokenSource(String string) { Lexer l = lexer.get(); l.setCharStream(new ANTLRStringStream(string)); return l; }
Example 9
Source File: AntlrProposalConflictHelper.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected void initTokenSource(String text, TokenSource tokenSource, ContentAssistContext context) { Lexer lexer = (Lexer) tokenSource; CharStream stream = new ANTLRStringStream(text); lexer.setCharStream(stream); }