Handle nil keyword
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
a3e77f650a
commit
cf1daf7805
|
@ -366,6 +366,8 @@ namespace Porygon::Binder {
|
|||
case ParsedExpressionKind::LiteralBool:
|
||||
return new BoundLiteralBoolExpression(((LiteralBoolExpression *) expression)->GetValue(),
|
||||
expression->GetStartPosition(), expression->GetLength());
|
||||
case ParsedExpressionKind ::Nil:
|
||||
return new BoundNilExpression(expression->GetStartPosition(), expression->GetLength());
|
||||
case ParsedExpressionKind::Variable:
|
||||
return this->BindVariableExpression((VariableExpression *) expression);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Porygon::Binder {
|
|||
LiteralFloat,
|
||||
LiteralString,
|
||||
LiteralBool,
|
||||
Nil,
|
||||
Variable,
|
||||
|
||||
Unary,
|
||||
|
@ -152,6 +153,18 @@ namespace Porygon::Binder {
|
|||
}
|
||||
};
|
||||
|
||||
class BoundNilExpression : public BoundExpression {
|
||||
public:
|
||||
BoundNilExpression(unsigned int start, unsigned int length)
|
||||
: BoundExpression(start, length, ScriptType::NilType)
|
||||
{ }
|
||||
|
||||
[[nodiscard]]
|
||||
inline BoundExpressionKind GetKind() const final {
|
||||
return BoundExpressionKind::Nil;
|
||||
}
|
||||
};
|
||||
|
||||
class BoundVariableExpression : public BoundExpression {
|
||||
const BoundVariableKey *_key;
|
||||
public:
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "EvaluationScope/EvaluationScope.hpp"
|
||||
#include "EvalValues/ScriptFunctionEvalValue.hpp"
|
||||
#include "EvalValues/TableEvalValue.hpp"
|
||||
#include "EvalValues/NilEvalValue.hpp"
|
||||
#include "../Binder/BoundExpressions/BoundTableExpression.hpp"
|
||||
#include "../Binder/BoundExpressions/BoundFunctionCallExpression.hpp"
|
||||
#include "../Binder/BoundExpressions/BoundRequireExpression.hpp"
|
||||
|
@ -239,6 +240,8 @@ namespace Porygon::Evaluation {
|
|||
return new StringEvalValue(*((BoundLiteralStringExpression *) expression)->GetValue());
|
||||
case BoundExpressionKind::LiteralBool:
|
||||
return new BooleanEvalValue(((BoundLiteralBoolExpression *) expression)->GetValue());
|
||||
case BoundExpressionKind::Nil:
|
||||
return new NilEvalValue();
|
||||
case BoundExpressionKind::Variable:
|
||||
return this -> GetVariable((BoundVariableExpression*)expression);
|
||||
case BoundExpressionKind::Unary:
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace Porygon::Parser {
|
|||
LiteralFloat,
|
||||
LiteralString,
|
||||
LiteralBool,
|
||||
Nil,
|
||||
Variable,
|
||||
|
||||
Unary,
|
||||
|
@ -133,6 +134,17 @@ namespace Porygon::Parser {
|
|||
}
|
||||
};
|
||||
|
||||
class NilExpression : public ParsedExpression {
|
||||
public:
|
||||
[[nodiscard]] inline const ParsedExpressionKind GetKind() const final {
|
||||
return ParsedExpressionKind::Nil;
|
||||
}
|
||||
|
||||
explicit NilExpression(const Token *token)
|
||||
: ParsedExpression(token->GetStartPosition(), token->GetLength()) {
|
||||
}
|
||||
};
|
||||
|
||||
class VariableExpression : public ParsedExpression {
|
||||
const HashedString _value;
|
||||
public:
|
||||
|
|
|
@ -496,6 +496,8 @@ namespace Porygon::Parser {
|
|||
return new LiteralBoolExpression(current);
|
||||
case TokenKind::FalseKeyword:
|
||||
return new LiteralBoolExpression(current);
|
||||
case TokenKind::NilKeyword:
|
||||
return new NilExpression(current);
|
||||
case TokenKind::Identifier:
|
||||
return new VariableExpression(dynamic_cast<const IdentifierToken*>(current));
|
||||
case TokenKind::OpenParenthesis:
|
||||
|
|
Loading…
Reference in New Issue