public function parse(Parser $parser)
{
$lexer = $parser->getLexer();
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->listaggField = $parser->StringPrimary();
if ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->separator = $parser->StringExpression();
}
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
if (!$lexer->isNextToken(Lexer::T_IDENTIFIER) || strtolower($lexer->lookahead['value']) != 'within') {
$parser->syntaxError('WITHIN GROUP');
}
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_GROUP);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
$this->orderBy = $parser->OrderByClause();
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
if ($lexer->isNextToken(Lexer::T_IDENTIFIER)) {
if (strtolower($lexer->lookahead['value']) != 'over') {
$parser->syntaxError('OVER');
}
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_OPEN_PARENTHESIS);
if (!$lexer->isNextToken(Lexer::T_IDENTIFIER) || strtolower($lexer->lookahead['value']) != 'partition') {
$parser->syntaxError('PARTITION BY');
}
$parser->match(Lexer::T_IDENTIFIER);
$parser->match(Lexer::T_BY);
$this->partitionBy[] = $parser->StringPrimary();
while ($lexer->isNextToken(Lexer::T_COMMA)) {
$parser->match(Lexer::T_COMMA);
$this->partitionBy[] = $parser->StringPrimary();
}
$parser->match(Lexer::T_CLOSE_PARENTHESIS);
}
}