use of org.eclipse.xtext.testlanguages.parser.antlr.internal.InternalSimpleExpressionsTestLanguageLexer in project xtext-core by eclipse.
the class LexerErrorTest method testLexerError_02.
@Test
public void testLexerError_02() throws Exception {
String model = "a 'incomplete string";
InternalSimpleExpressionsTestLanguageLexer lexer = new InternalSimpleExpressionsTestLanguageLexer();
lexer.setCharStream(new ANTLRStringStream(model));
CommonTokenStream stream = new CommonTokenStream(lexer);
@SuppressWarnings("unchecked") List<CommonToken> tokens = stream.getTokens();
assertEquals(tokens.toString(), 3, tokens.size());
assertEquals("a", tokens.get(0).getText());
assertEquals(" ", tokens.get(1).getText());
assertEquals("'incomplete string", tokens.get(2).getText());
assertEquals(0, tokens.get(2).getType());
}
use of org.eclipse.xtext.testlanguages.parser.antlr.internal.InternalSimpleExpressionsTestLanguageLexer in project xtext-core by eclipse.
the class LexerErrorTest method testLexerError_04.
@Test
public void testLexerError_04() throws Exception {
String model = "a 'incomplete string with bad escape sequence \\";
InternalSimpleExpressionsTestLanguageLexer lexer = new InternalSimpleExpressionsTestLanguageLexer();
lexer.setCharStream(new ANTLRStringStream(model));
CommonTokenStream stream = new CommonTokenStream(lexer);
@SuppressWarnings("unchecked") List<CommonToken> tokens = stream.getTokens();
assertEquals(tokens.toString(), 3, tokens.size());
assertEquals("a", tokens.get(0).getText());
assertEquals(" ", tokens.get(1).getText());
assertEquals("'incomplete string with bad escape sequence \\", tokens.get(2).getText());
assertEquals(0, tokens.get(2).getType());
}
use of org.eclipse.xtext.testlanguages.parser.antlr.internal.InternalSimpleExpressionsTestLanguageLexer in project xtext-core by eclipse.
the class LexerErrorTest method testLexerError_03.
@Test
public void testLexerError_03() throws Exception {
String model = "a '\\ incomplete string with bad escape sequence";
InternalSimpleExpressionsTestLanguageLexer lexer = new InternalSimpleExpressionsTestLanguageLexer();
lexer.setCharStream(new ANTLRStringStream(model));
CommonTokenStream stream = new CommonTokenStream(lexer);
@SuppressWarnings("unchecked") List<CommonToken> tokens = stream.getTokens();
assertEquals(tokens.toString(), 3, tokens.size());
assertEquals("a", tokens.get(0).getText());
assertEquals(" ", tokens.get(1).getText());
assertEquals("'\\ incomplete string with bad escape sequence", tokens.get(2).getText());
assertEquals(0, tokens.get(2).getType());
}
use of org.eclipse.xtext.testlanguages.parser.antlr.internal.InternalSimpleExpressionsTestLanguageLexer in project xtext-core by eclipse.
the class LexerSLComment method testSlComment.
@Test
public void testSlComment() {
String model = "//sl comment\na";
InternalSimpleExpressionsTestLanguageLexer lexer = new InternalSimpleExpressionsTestLanguageLexer();
lexer.setCharStream(new ANTLRStringStream(model));
CommonTokenStream stream = new CommonTokenStream(lexer);
Object inLineComment = stream.getTokens().get(0);
assertTrue(inLineComment instanceof CommonToken);
assertEquals(InternalSimpleExpressionsTestLanguageLexer.RULE_SL_COMMENT, ((CommonToken) inLineComment).getType());
}
use of org.eclipse.xtext.testlanguages.parser.antlr.internal.InternalSimpleExpressionsTestLanguageLexer in project xtext-core by eclipse.
the class LexerSLComment method testSlCommentEOF.
/**
* see BUG 234135: Comments on EOF not detected
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=234135
*/
@Test
public void testSlCommentEOF() {
String model = "a\n//sl comment";
InternalSimpleExpressionsTestLanguageLexer lexer = new InternalSimpleExpressionsTestLanguageLexer();
lexer.setCharStream(new ANTLRStringStream(model));
CommonTokenStream stream = new CommonTokenStream(lexer);
Object eofLineComment = stream.getTokens().get(2);
assertTrue(eofLineComment instanceof CommonToken);
CommonToken commonToken = (CommonToken) eofLineComment;
int type = commonToken.getType();
assertEquals(InternalSimpleExpressionsTestLanguageLexer.RULE_SL_COMMENT, type);
}
Aggregations