|
@ -169,7 +169,7 @@ ASTPointer<InheritanceSpecifier> Parser::parseInheritanceSpecifier() |
|
|
if (m_scanner->getCurrentToken() == Token::LPAREN) |
|
|
if (m_scanner->getCurrentToken() == Token::LPAREN) |
|
|
{ |
|
|
{ |
|
|
m_scanner->next(); |
|
|
m_scanner->next(); |
|
|
arguments = parseFunctionCallArguments(); |
|
|
arguments = parseFunctionCallListArguments(); |
|
|
nodeFactory.markEndPosition(); |
|
|
nodeFactory.markEndPosition(); |
|
|
expectToken(Token::RPAREN); |
|
|
expectToken(Token::RPAREN); |
|
|
} |
|
|
} |
|
@ -332,7 +332,7 @@ ASTPointer<ModifierInvocation> Parser::parseModifierInvocation() |
|
|
if (m_scanner->getCurrentToken() == Token::LPAREN) |
|
|
if (m_scanner->getCurrentToken() == Token::LPAREN) |
|
|
{ |
|
|
{ |
|
|
m_scanner->next(); |
|
|
m_scanner->next(); |
|
|
arguments = parseFunctionCallArguments(); |
|
|
arguments = parseFunctionCallListArguments(); |
|
|
nodeFactory.markEndPosition(); |
|
|
nodeFactory.markEndPosition(); |
|
|
expectToken(Token::RPAREN); |
|
|
expectToken(Token::RPAREN); |
|
|
} |
|
|
} |
|
@ -592,7 +592,6 @@ ASTPointer<Expression> Parser::parseBinaryExpression(int _minPrecedence) |
|
|
ASTPointer<Expression> expression = parseUnaryExpression(); |
|
|
ASTPointer<Expression> expression = parseUnaryExpression(); |
|
|
int precedence = Token::precedence(m_scanner->getCurrentToken()); |
|
|
int precedence = Token::precedence(m_scanner->getCurrentToken()); |
|
|
for (; precedence >= _minPrecedence; --precedence) |
|
|
for (; precedence >= _minPrecedence; --precedence) |
|
|
{ |
|
|
|
|
|
while (Token::precedence(m_scanner->getCurrentToken()) == precedence) |
|
|
while (Token::precedence(m_scanner->getCurrentToken()) == precedence) |
|
|
{ |
|
|
{ |
|
|
Token::Value op = m_scanner->getCurrentToken(); |
|
|
Token::Value op = m_scanner->getCurrentToken(); |
|
@ -601,7 +600,6 @@ ASTPointer<Expression> Parser::parseBinaryExpression(int _minPrecedence) |
|
|
nodeFactory.setEndPositionFromNode(right); |
|
|
nodeFactory.setEndPositionFromNode(right); |
|
|
expression = nodeFactory.createNode<BinaryOperation>(expression, op, right); |
|
|
expression = nodeFactory.createNode<BinaryOperation>(expression, op, right); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
return expression; |
|
|
return expression; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -667,10 +665,12 @@ ASTPointer<Expression> Parser::parseLeftHandSideExpression() |
|
|
case Token::LPAREN: |
|
|
case Token::LPAREN: |
|
|
{ |
|
|
{ |
|
|
m_scanner->next(); |
|
|
m_scanner->next(); |
|
|
vector<ASTPointer<Expression>> arguments = parseFunctionCallArguments(); |
|
|
vector<ASTPointer<Expression>> arguments; |
|
|
|
|
|
vector<ASTPointer<ASTString>> names; |
|
|
|
|
|
std::tie(arguments, names) = parseFunctionCallArguments(); |
|
|
nodeFactory.markEndPosition(); |
|
|
nodeFactory.markEndPosition(); |
|
|
expectToken(Token::RPAREN); |
|
|
expectToken(Token::RPAREN); |
|
|
expression = nodeFactory.createNode<FunctionCall>(expression, arguments); |
|
|
expression = nodeFactory.createNode<FunctionCall>(expression, arguments, names); |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
@ -723,7 +723,7 @@ ASTPointer<Expression> Parser::parsePrimaryExpression() |
|
|
return expression; |
|
|
return expression; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
vector<ASTPointer<Expression>> Parser::parseFunctionCallArguments() |
|
|
vector<ASTPointer<Expression>> Parser::parseFunctionCallListArguments() |
|
|
{ |
|
|
{ |
|
|
vector<ASTPointer<Expression>> arguments; |
|
|
vector<ASTPointer<Expression>> arguments; |
|
|
if (m_scanner->getCurrentToken() != Token::RPAREN) |
|
|
if (m_scanner->getCurrentToken() != Token::RPAREN) |
|
@ -738,6 +738,32 @@ vector<ASTPointer<Expression>> Parser::parseFunctionCallArguments() |
|
|
return arguments; |
|
|
return arguments; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pair<vector<ASTPointer<Expression>>, vector<ASTPointer<ASTString>>> Parser::parseFunctionCallArguments() |
|
|
|
|
|
{ |
|
|
|
|
|
pair<vector<ASTPointer<Expression>>, vector<ASTPointer<ASTString>>> ret; |
|
|
|
|
|
Token::Value token = m_scanner->getCurrentToken(); |
|
|
|
|
|
if (token == Token::LBRACE) |
|
|
|
|
|
{ |
|
|
|
|
|
// call({arg1 : 1, arg2 : 2 })
|
|
|
|
|
|
expectToken(Token::LBRACE); |
|
|
|
|
|
while (m_scanner->getCurrentToken() != Token::RBRACE) |
|
|
|
|
|
{ |
|
|
|
|
|
ret.second.push_back(expectIdentifierToken()); |
|
|
|
|
|
expectToken(Token::COLON); |
|
|
|
|
|
ret.first.push_back(parseExpression()); |
|
|
|
|
|
|
|
|
|
|
|
if (m_scanner->getCurrentToken() == Token::COMMA) |
|
|
|
|
|
expectToken(Token::COMMA); |
|
|
|
|
|
else |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
expectToken(Token::RBRACE); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
ret.first = parseFunctionCallListArguments(); |
|
|
|
|
|
return ret; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Parser::peekVariableDefinition() |
|
|
bool Parser::peekVariableDefinition() |
|
|
{ |
|
|
{ |
|
|