Cleanup of Parsed Expression classes
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:
@@ -42,17 +42,17 @@ namespace Porygon::Parser {
|
|||||||
|
|
||||||
virtual ~ParsedExpression() = default;
|
virtual ~ParsedExpression() = default;
|
||||||
|
|
||||||
virtual const ParsedExpressionKind GetKind() const = 0;
|
[[nodiscard]] virtual ParsedExpressionKind GetKind() const = 0;
|
||||||
|
|
||||||
inline const unsigned int GetStartPosition() const {
|
[[nodiscard]] inline unsigned int GetStartPosition() const {
|
||||||
return _position;
|
return _position;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const unsigned int GetEndPosition() const {
|
[[nodiscard]] inline unsigned int GetEndPosition() const {
|
||||||
return _position + _length - 1;
|
return _position + _length - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const unsigned int GetLength() const {
|
[[nodiscard]] inline unsigned int GetLength() const {
|
||||||
return _length;
|
return _length;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -61,7 +61,7 @@ namespace Porygon::Parser {
|
|||||||
public:
|
public:
|
||||||
BadExpression(unsigned int position, unsigned int length) : ParsedExpression(position, length) {}
|
BadExpression(unsigned int position, unsigned int length) : ParsedExpression(position, length) {}
|
||||||
|
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::Bad;
|
return ParsedExpressionKind::Bad;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -69,7 +69,7 @@ namespace Porygon::Parser {
|
|||||||
class LiteralIntegerExpression : public ParsedExpression {
|
class LiteralIntegerExpression : public ParsedExpression {
|
||||||
const int64_t _value;
|
const int64_t _value;
|
||||||
public:
|
public:
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::LiteralInteger;
|
return ParsedExpressionKind::LiteralInteger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ namespace Porygon::Parser {
|
|||||||
_value(token->GetValue()) {
|
_value(token->GetValue()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const int64_t GetValue() const {
|
[[nodiscard]] inline int64_t GetValue() const {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -86,7 +86,7 @@ namespace Porygon::Parser {
|
|||||||
class LiteralFloatExpression : public ParsedExpression {
|
class LiteralFloatExpression : public ParsedExpression {
|
||||||
const double _value;
|
const double _value;
|
||||||
public:
|
public:
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::LiteralFloat;
|
return ParsedExpressionKind::LiteralFloat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ namespace Porygon::Parser {
|
|||||||
_value(token->GetValue()) {
|
_value(token->GetValue()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const double GetValue() const {
|
[[nodiscard]] inline double GetValue() const {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -103,7 +103,7 @@ namespace Porygon::Parser {
|
|||||||
class LiteralStringExpression : public ParsedExpression {
|
class LiteralStringExpression : public ParsedExpression {
|
||||||
const u16string _value;
|
const u16string _value;
|
||||||
public:
|
public:
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::LiteralString;
|
return ParsedExpressionKind::LiteralString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ namespace Porygon::Parser {
|
|||||||
_value(token->GetValue()) {
|
_value(token->GetValue()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const u16string &GetValue() const {
|
[[nodiscard]] inline const u16string &GetValue() const {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -120,7 +120,7 @@ namespace Porygon::Parser {
|
|||||||
class LiteralBoolExpression : public ParsedExpression {
|
class LiteralBoolExpression : public ParsedExpression {
|
||||||
const bool _value;
|
const bool _value;
|
||||||
public:
|
public:
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]]inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::LiteralBool;
|
return ParsedExpressionKind::LiteralBool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,14 +129,14 @@ namespace Porygon::Parser {
|
|||||||
_value(token->GetKind() == TokenKind::TrueKeyword) {
|
_value(token->GetKind() == TokenKind::TrueKeyword) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const bool GetValue() const {
|
[[nodiscard]]inline bool GetValue() const {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class NilExpression : public ParsedExpression {
|
class NilExpression : public ParsedExpression {
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::Nil;
|
return ParsedExpressionKind::Nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ namespace Porygon::Parser {
|
|||||||
class VariableExpression : public ParsedExpression {
|
class VariableExpression : public ParsedExpression {
|
||||||
const HashedString _value;
|
const HashedString _value;
|
||||||
public:
|
public:
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]]inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::Variable;
|
return ParsedExpressionKind::Variable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,7 +157,7 @@ namespace Porygon::Parser {
|
|||||||
_value(HashedString(token->GetValue())) {
|
_value(HashedString(token->GetValue())) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const HashedString GetValue() const {
|
[[nodiscard]]inline HashedString GetValue() const {
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -170,7 +170,7 @@ namespace Porygon::Parser {
|
|||||||
delete _expression;
|
delete _expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::Parenthesized;
|
return ParsedExpressionKind::Parenthesized;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ namespace Porygon::Parser {
|
|||||||
: ParsedExpression(start, length), _expression(innerExpression) {
|
: ParsedExpression(start, length), _expression(innerExpression) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpression *GetInnerExpression() const {
|
[[nodiscard]]inline const ParsedExpression *GetInnerExpression() const {
|
||||||
return _expression;
|
return _expression;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -191,7 +191,7 @@ namespace Porygon::Parser {
|
|||||||
delete _operand;
|
delete _operand;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]]inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::Unary;
|
return ParsedExpressionKind::Unary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,11 +200,11 @@ namespace Porygon::Parser {
|
|||||||
_kind(kind), _operand(operand) {
|
_kind(kind), _operand(operand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const UnaryOperatorKind GetOperatorKind() const {
|
[[nodiscard]]inline UnaryOperatorKind GetOperatorKind() const {
|
||||||
return _kind;
|
return _kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpression *GetOperand() const {
|
[[nodiscard]]inline const ParsedExpression *GetOperand() const {
|
||||||
return _operand;
|
return _operand;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -219,7 +219,7 @@ namespace Porygon::Parser {
|
|||||||
delete _right;
|
delete _right;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]]inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::Binary;
|
return ParsedExpressionKind::Binary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,15 +229,15 @@ namespace Porygon::Parser {
|
|||||||
_kind(kind), _left(left), _right(right) {
|
_kind(kind), _left(left), _right(right) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const BinaryOperatorKind GetOperatorKind() const {
|
[[nodiscard]]inline BinaryOperatorKind GetOperatorKind() const {
|
||||||
return _kind;
|
return _kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpression *GetLeft() const {
|
[[nodiscard]]inline const ParsedExpression *GetLeft() const {
|
||||||
return _left;
|
return _left;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpression *GetRight() const {
|
[[nodiscard]]inline const ParsedExpression *GetRight() const {
|
||||||
return _right;
|
return _right;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -258,15 +258,15 @@ namespace Porygon::Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::FunctionCall;
|
return ParsedExpressionKind::FunctionCall;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpression *GetFunction() const {
|
[[nodiscard]] inline const ParsedExpression *GetFunction() const {
|
||||||
return _function.get();
|
return _function.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const vector<const ParsedExpression *> *GetParameters() const {
|
[[nodiscard]] inline const vector<const ParsedExpression *> *GetParameters() const {
|
||||||
return &_parameters;
|
return &_parameters;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -285,15 +285,15 @@ namespace Porygon::Parser {
|
|||||||
delete _indexExpression;
|
delete _indexExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::Indexer;
|
return ParsedExpressionKind::Indexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpression *GetIndexer() const {
|
[[nodiscard]] inline const ParsedExpression *GetIndexer() const {
|
||||||
return _indexerExpression;
|
return _indexerExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpression *GetIndex() const {
|
[[nodiscard]] inline const ParsedExpression *GetIndex() const {
|
||||||
return _indexExpression;
|
return _indexExpression;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -302,7 +302,7 @@ namespace Porygon::Parser {
|
|||||||
const ParsedExpression *_indexerExpression;
|
const ParsedExpression *_indexerExpression;
|
||||||
const HashedString _index;
|
const HashedString _index;
|
||||||
public:
|
public:
|
||||||
PeriodIndexExpression(ParsedExpression *indexer, HashedString index, unsigned int start, unsigned int length)
|
PeriodIndexExpression(ParsedExpression *indexer, const HashedString& index, unsigned int start, unsigned int length)
|
||||||
: ParsedExpression(start, length),
|
: ParsedExpression(start, length),
|
||||||
_indexerExpression(indexer), _index(index) {
|
_indexerExpression(indexer), _index(index) {
|
||||||
}
|
}
|
||||||
@@ -311,15 +311,15 @@ namespace Porygon::Parser {
|
|||||||
delete _indexerExpression;
|
delete _indexerExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::PeriodIndexer;
|
return ParsedExpressionKind::PeriodIndexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpression *GetIndexer() const {
|
[[nodiscard]] inline const ParsedExpression *GetIndexer() const {
|
||||||
return _indexerExpression;
|
return _indexerExpression;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const HashedString &GetIndex() const {
|
[[nodiscard]] inline const HashedString &GetIndex() const {
|
||||||
return _index;
|
return _index;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -339,11 +339,11 @@ namespace Porygon::Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const vector<const ParsedExpression *> *GetExpressions() const {
|
[[nodiscard]] inline const vector<const ParsedExpression *> *GetExpressions() const {
|
||||||
return &_expressions;
|
return &_expressions;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] inline ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::NumericalTable;
|
return ParsedExpressionKind::NumericalTable;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ namespace Porygon::Parser {
|
|||||||
delete _block;
|
delete _block;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ParsedBlockStatement *GetBlock() const {
|
[[nodiscard]] const ParsedBlockStatement *GetBlock() const {
|
||||||
return _block;
|
return _block;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ParsedExpressionKind GetKind() const final {
|
[[nodiscard]] ParsedExpressionKind GetKind() const final {
|
||||||
return ParsedExpressionKind::Table;
|
return ParsedExpressionKind::Table;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user