use of org.apache.geode.cache.query.internal.parse.OQLLexer in project geode by apache.
the class QCompiler method compileImports.
/**
* Processes import statements only. This compiler instance remembers the imports and can be used
* to compile other strings with this context info
*/
public void compileImports(String imports) {
try {
OQLLexer lexer = new OQLLexer(new StringReader(imports));
OQLParser parser = new OQLParser(lexer);
// by default use Unsupported AST class, overridden for supported
// operators in the grammer proper
parser.setASTNodeClass("org.apache.geode.cache.query.internal.parse.ASTUnsupported");
parser.loneImports();
GemFireAST n = (GemFireAST) parser.getAST();
n.compile(this);
} catch (Exception ex) {
// GemFire Exception.
throw new QueryInvalidException(LocalizedStrings.QCompiler_SYNTAX_ERROR_IN_QUERY_0.toLocalizedString(ex.getMessage()), ex);
}
Assert.assertTrue(stackSize() == 0, "stack size = " + stackSize() + ";stack=" + this.stack);
}
use of org.apache.geode.cache.query.internal.parse.OQLLexer in project geode by apache.
the class QCompiler method compileProjectionAttributes.
/** Returns List<CompiledIteratorDef> or null if projectionAttrs is '*' */
public List compileProjectionAttributes(String projectionAttributes) {
try {
OQLLexer lexer = new OQLLexer(new StringReader(projectionAttributes));
OQLParser parser = new OQLParser(lexer);
// by default use Unsupported AST class, overridden for supported
// operators in the grammer proper
parser.setASTNodeClass("org.apache.geode.cache.query.internal.parse.ASTUnsupported");
parser.loneProjectionAttributes();
GemFireAST n = (GemFireAST) parser.getAST();
// don't compile TOK_STAR
if (n.getType() == TOK_STAR) {
return null;
}
n.compile(this);
} catch (Exception ex) {
// GemFire Exception.
throw new QueryInvalidException(LocalizedStrings.QCompiler_SYNTAX_ERROR_IN_QUERY_0.toLocalizedString(ex.getMessage()), ex);
}
Assert.assertTrue(stackSize() == 1, "stack size = " + stackSize() + ";stack=" + this.stack);
return (List) pop();
}
use of org.apache.geode.cache.query.internal.parse.OQLLexer in project geode by apache.
the class QCompiler method compileQuery.
/*
* compile the string into a Query (returns the root CompiledValue)
*/
public CompiledValue compileQuery(String oqlSource) {
try {
OQLLexer lexer = new OQLLexer(new StringReader(oqlSource));
OQLParser parser = new OQLParser(lexer);
// by default use Unsupported AST class, overridden for supported
// operators in the grammer proper
parser.setASTNodeClass("org.apache.geode.cache.query.internal.parse.ASTUnsupported");
parser.queryProgram();
GemFireAST n = (GemFireAST) parser.getAST();
n.compile(this);
} catch (Exception ex) {
// GemFire Exception.
throw new QueryInvalidException(LocalizedStrings.QCompiler_SYNTAX_ERROR_IN_QUERY_0.toLocalizedString(ex.getMessage()), ex);
}
Assert.assertTrue(stackSize() == 1, "stack size = " + stackSize());
return (CompiledValue) pop();
}
use of org.apache.geode.cache.query.internal.parse.OQLLexer in project geode by apache.
the class QCompiler method compileFromClause.
/** Returns List<CompiledIteratorDef> */
public List compileFromClause(String fromClause) {
try {
OQLLexer lexer = new OQLLexer(new StringReader(fromClause));
OQLParser parser = new OQLParser(lexer);
// by default use Unsupported AST class, overridden for supported
// operators in the grammer proper
parser.setASTNodeClass("org.apache.geode.cache.query.internal.parse.ASTUnsupported");
parser.loneFromClause();
GemFireAST n = (GemFireAST) parser.getAST();
n.compile(this);
} catch (Exception ex) {
// GemFire Exception.
throw new QueryInvalidException(LocalizedStrings.QCompiler_SYNTAX_ERROR_IN_QUERY_0.toLocalizedString(ex.getMessage()), ex);
}
Assert.assertTrue(stackSize() == 1, "stack size = " + stackSize());
return (List) pop();
}
Aggregations