Implements complex tables
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "UnaryOperatorKind.hpp"
|
||||
#include "BinaryOperatorKind.hpp"
|
||||
#include "TypedVariableIdentifier.hpp"
|
||||
#include "ParsedExpressions/ParsedTableExpression.hpp"
|
||||
|
||||
|
||||
ParsedScriptStatement* Parser::Parse() {
|
||||
@@ -372,6 +373,7 @@ ParsedExpression* Parser::ParseTableExpression(IToken* current){
|
||||
auto start = current->GetStartPosition();
|
||||
return new ParsedNumericalTableExpression({}, start, this -> Peek()->GetEndPosition() - start);
|
||||
}
|
||||
auto start = current->GetStartPosition();
|
||||
auto firstItem = this->ParseStatement(this -> Next());
|
||||
// If the first item is an expression, and is followed by a comma, we're dealing with a simple {1, 2, 3} kind of array
|
||||
if (firstItem->GetKind() == ParsedStatementKind::Expression &&
|
||||
@@ -389,7 +391,6 @@ ParsedExpression* Parser::ParseTableExpression(IToken* current){
|
||||
hasErrors = true;
|
||||
}
|
||||
}
|
||||
auto start = current->GetStartPosition();
|
||||
if (hasErrors){
|
||||
return new BadExpression(start, n->GetEndPosition() - start);
|
||||
}
|
||||
@@ -400,7 +401,8 @@ ParsedExpression* Parser::ParseTableExpression(IToken* current){
|
||||
auto block = (ParsedBlockStatement*)this -> ParseBlock({TokenKind ::CloseCurlyBracket});
|
||||
auto statements = block->GetStatements();
|
||||
statements->insert(statements->begin(), firstItem);
|
||||
throw "not implemented TODO";
|
||||
auto closeToken = this -> PeekAt(-1);
|
||||
return new ParsedTableExpression(block, start, closeToken->GetEndPosition() - start);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user