use of org.antlr.runtime.CommonTokenStream in project cuba by cuba-platform.
the class Jpa2GrammarTest method testMemberOf.
@Test
@Disabled
public void testMemberOf() throws Exception {
String query = "where p.owner.id = :userParam or (select u from tamsy$User u where u.id = :userParam) member of p.developers";
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.where_clause_return aReturn = jpa2Parser.where_clause();
Assertions.assertTrue(isValid((CommonTree) aReturn.getTree()));
testQuery("SELECT d FROM app$Department d WHERE (select e from app$Employee e where e.id = :eParam) MEMBER OF e.employees");
testQuery("SELECT e FROM app$Employee e WHERE 'write code' MEMBER OF e.codes");
testQuery("SELECT e FROM app$Employee e WHERE 'write code' NOT MEMBER OF e.codes");
}
use of org.antlr.runtime.CommonTokenStream in project cuba by cuba-platform.
the class Jpa2GrammarTest method testUpdate.
@Test
public void testUpdate() throws Exception {
String query = "update sec$User u set u.group = :group where u.id = :userId";
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.update_statement_return aReturn = jpa2Parser.update_statement();
Assertions.assertTrue(isValid((CommonTree) aReturn.getTree()));
}
use of org.antlr.runtime.CommonTokenStream in project cuba by cuba-platform.
the class Jpa2GrammarTest method testQuery.
private void testQuery(String query) throws RecognitionException {
CharStream cs = new AntlrNoCaseStringStream(query);
JPA2Lexer lexer = new JPA2Lexer(cs);
TokenStream tstream = new CommonTokenStream(lexer);
JPA2Parser jpa2Parser = new JPA2Parser(tstream);
JPA2Parser.ql_statement_return aReturn = jpa2Parser.ql_statement();
Assertions.assertTrue(isValid((CommonTree) aReturn.getTree()));
}
use of org.antlr.runtime.CommonTokenStream 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.antlr.runtime.CommonTokenStream 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