protected void compilePrimary()
{
if (p.parseStringIgnoreCase("DISTINCT"))
{
// Aggregates can have "count(DISTINCT field1)"
Node distinctNode = new Node(Node.OPERATOR, "DISTINCT");
compileIdentifier();
Node identifierNode = (Node)stack.pop();
distinctNode.appendChildNode(identifierNode);
stack.push(distinctNode);
return;
}
if (compileLiteral())
{
return;
}
if (compileMethod())
{
return;
}
if (p.parseChar('('))
{
compileExpression();
if (!p.parseChar(')'))
{
throw new QueryCompilerSyntaxException("expected ')'", p.getIndex(), p.getInput());
}
return;
}
// if primary == null, literal not found...
// We will have an identifier (variable, parameter, or field of candidate class)
if (!compileIdentifier())
{
throw new QueryCompilerSyntaxException("Identifier expected", p.getIndex(), p.getInput());
}
int size = stack.size();
/*
* run function on literals or identifiers
* e.g. "primary.runMethod(arg)"
*/
while (p.parseChar('.'))
{
if (compileMethod())
{
//((ExpressionNode) stack.pop()).addChildNode((ExpressionNode) stack.pop());
}
else
{
if (!compileIdentifier())
{
throw new QueryCompilerSyntaxException("Identifier expected", p.getIndex(), p.getInput());
}
}
}
while (stack.size() > size)
{
Node top = (Node) stack.pop();
Node peek = ((Node) stack.peek());
peek.insertChildNode(top);
}
}