patterns: Fixed using declaration parsing
This commit is contained in:
parent
ec9715f326
commit
140234aef3
@ -511,12 +511,13 @@ namespace hex::pl {
|
|||||||
auto originalPos = this->m_curr;
|
auto originalPos = this->m_curr;
|
||||||
parseNamespaceResolution();
|
parseNamespaceResolution();
|
||||||
bool isFunction = peek(SEPARATOR_ROUNDBRACKETOPEN);
|
bool isFunction = peek(SEPARATOR_ROUNDBRACKETOPEN);
|
||||||
this->m_curr = originalPos;
|
|
||||||
|
|
||||||
if (isFunction) {
|
if (isFunction) {
|
||||||
|
this->m_curr = originalPos;
|
||||||
statement = parseFunctionCall();
|
statement = parseFunctionCall();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
this->m_curr = originalPos - 1;
|
||||||
statement = parseFunctionVariableDecl();
|
statement = parseFunctionVariableDecl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -749,7 +750,11 @@ namespace hex::pl {
|
|||||||
|
|
||||||
// using Identifier = (parseType)
|
// using Identifier = (parseType)
|
||||||
ASTNode* Parser::parseUsingDeclaration() {
|
ASTNode* Parser::parseUsingDeclaration() {
|
||||||
auto name = getValue<Token::Identifier>(-2).get();
|
auto name = parseNamespaceResolution();
|
||||||
|
|
||||||
|
if (!MATCHES(sequence(OPERATOR_ASSIGNMENT)))
|
||||||
|
throwParseError("expected '=' after type name of using declaration");
|
||||||
|
|
||||||
auto *type = dynamic_cast<ASTNodeTypeDecl *>(parseType());
|
auto *type = dynamic_cast<ASTNodeTypeDecl *>(parseType());
|
||||||
if (type == nullptr) throwParseError("invalid type used in variable declaration", -1);
|
if (type == nullptr) throwParseError("invalid type used in variable declaration", -1);
|
||||||
|
|
||||||
@ -1110,7 +1115,7 @@ namespace hex::pl {
|
|||||||
std::vector<ASTNode*> Parser::parseStatements() {
|
std::vector<ASTNode*> Parser::parseStatements() {
|
||||||
ASTNode *statement;
|
ASTNode *statement;
|
||||||
|
|
||||||
if (MATCHES(sequence(KEYWORD_USING, IDENTIFIER, OPERATOR_ASSIGNMENT)))
|
if (MATCHES(sequence(KEYWORD_USING, IDENTIFIER)))
|
||||||
statement = parseUsingDeclaration();
|
statement = parseUsingDeclaration();
|
||||||
else if (peek(IDENTIFIER)) {
|
else if (peek(IDENTIFIER)) {
|
||||||
auto originalPos = this->m_curr;
|
auto originalPos = this->m_curr;
|
||||||
|
Loading…
Reference in New Issue
Block a user