Search in sources :

Example 1 with FlexerFactory

use of org.eclipse.xtend.core.parser.antlr.internal.FlexerFactory in project xtext-xtend by eclipse.

the class LexerBenchmark method setUp.

@Override
protected void setUp() throws Exception {
    contentToParse = loadString();
    lexer = new InternalXtendLexer(null);
    flexerTokenSource = new FlexerFactory().createTokenSource(null);
    bareFlexer = new FlexerFactory().createFlexer(null);
}
Also used : FlexerFactory(org.eclipse.xtend.core.parser.antlr.internal.FlexerFactory) InternalXtendLexer(org.eclipse.xtend.core.parser.antlr.internal.InternalXtendLexer)

Example 2 with FlexerFactory

use of org.eclipse.xtend.core.parser.antlr.internal.FlexerFactory in project xtext-xtend by eclipse.

the class FlexingTest method assertLexing.

@Override
protected void assertLexing(String input, Pair<String, String>... expectedTokens) {
    FlexTokenSource tokenSource = new FlexerFactory().createTokenSource(new StringReader(input));
    XtextTokenStream tokenStream = new XtextTokenStream(tokenSource, getTokenDefProvider());
    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 = getTokenDefProvider().getTokenDefMap().get(token.getType());
        assertEquals("expected " + expected + " but was " + actual, expected, actual);
    }
}
Also used : FlexerFactory(org.eclipse.xtend.core.parser.antlr.internal.FlexerFactory) XtextTokenStream(org.eclipse.xtext.parser.antlr.XtextTokenStream) FlexTokenSource(org.eclipse.xtend.core.parser.antlr.internal.FlexTokenSource) StringReader(java.io.StringReader) Token(org.antlr.runtime.Token)

Aggregations

FlexerFactory (org.eclipse.xtend.core.parser.antlr.internal.FlexerFactory)2 StringReader (java.io.StringReader)1 Token (org.antlr.runtime.Token)1 FlexTokenSource (org.eclipse.xtend.core.parser.antlr.internal.FlexTokenSource)1 InternalXtendLexer (org.eclipse.xtend.core.parser.antlr.internal.InternalXtendLexer)1 XtextTokenStream (org.eclipse.xtext.parser.antlr.XtextTokenStream)1