Implements parsing function declarations
This commit is contained in:
@@ -1,9 +1,3 @@
|
||||
#include <utility>
|
||||
|
||||
#include <utility>
|
||||
|
||||
|
||||
|
||||
#ifndef PORYGONLANG_PARSEDSTATEMENT_HPP
|
||||
#define PORYGONLANG_PARSEDSTATEMENT_HPP
|
||||
|
||||
@@ -13,13 +7,15 @@
|
||||
|
||||
#include "../ParsedExpressions/ParsedExpression.hpp"
|
||||
#include "../../Utilities/HashedString.hpp"
|
||||
#include "../TypedVariableIdentifier.hpp"
|
||||
|
||||
enum class ParsedStatementKind{
|
||||
Bad,
|
||||
Script,
|
||||
Block,
|
||||
Expression,
|
||||
Assignment
|
||||
Assignment,
|
||||
FunctionDeclaration
|
||||
};
|
||||
|
||||
class ParsedStatement {
|
||||
@@ -105,6 +101,39 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class ParsedFunctionDeclarationStatement : public ParsedStatement{
|
||||
HashedString _identifier;
|
||||
vector<TypedVariableIdentifier*> _parameters;
|
||||
ParsedBlockStatement* _block;
|
||||
public:
|
||||
ParsedFunctionDeclarationStatement(HashedString identifier, vector<TypedVariableIdentifier*> parameters, ParsedBlockStatement* block,
|
||||
unsigned int start, unsigned int length)
|
||||
: ParsedStatement(start, length), _identifier(identifier), _parameters(std::move(parameters)), _block(block){};
|
||||
|
||||
~ParsedFunctionDeclarationStatement() override {
|
||||
for (auto v : _parameters){
|
||||
delete v;
|
||||
}
|
||||
delete _block;
|
||||
}
|
||||
|
||||
ParsedStatementKind GetKind() final{
|
||||
return ParsedStatementKind ::FunctionDeclaration;
|
||||
}
|
||||
|
||||
HashedString GetIdentifier(){
|
||||
return _identifier;
|
||||
}
|
||||
|
||||
vector<TypedVariableIdentifier*> GetParameters(){
|
||||
return _parameters;
|
||||
}
|
||||
|
||||
ParsedBlockStatement* GetBlock(){
|
||||
return _block;
|
||||
}
|
||||
};
|
||||
|
||||
class ParsedAssignmentStatement : public ParsedStatement{
|
||||
bool _local;
|
||||
HashedString _identifier;
|
||||
|
||||
Reference in New Issue
Block a user