Rework evaluation to use shared pointers, fix bugs

This commit is contained in:
2019-06-01 21:38:39 +02:00
parent 4408cf00cd
commit 6206fef4c5
17 changed files with 122 additions and 133 deletions

View File

@@ -1,4 +1,5 @@
#include <algorithm>
#include "Parser.hpp"
#include "ParsedStatements/ParsedStatement.hpp"
#include "UnaryOperatorKind.hpp"
@@ -65,7 +66,7 @@ ParsedStatement *Parser::ParseAssignment(IToken *current) {
return new ParsedAssignmentStatement(isLocal, ((IdentifierToken*)identifier) -> Value, expression, start, expression->GetEndPosition() - start);
}
ParsedStatement *Parser::ParseBlock(vector<TokenKind> endTokens) {
ParsedStatement *Parser::ParseBlock(const vector<TokenKind>& endTokens) {
vector<ParsedStatement*> statements;
while (true){
auto next = this -> Next();

View File

@@ -1,9 +1,9 @@
#include <utility>
#ifndef PORYGONLANG_PARSER_HPP
#define PORYGONLANG_PARSER_HPP
#include <utility>
#include <vector>
#include "ParsedStatements/ParsedStatement.hpp"
#include "../Script.hpp"
@@ -27,7 +27,7 @@ class Parser {
ParsedStatement* ParseStatement(IToken* current);
ParsedStatement* ParseAssignment(IToken* current);
ParsedStatement *ParseBlock(vector<TokenKind> endTokens);
ParsedStatement *ParseBlock(const vector<TokenKind>& endTokens);
ParsedStatement* ParseFunctionDeclaration(IToken* current);
ParsedExpression* ParseExpression(IToken* current);