Large chunk of work in parser for getting expressions to work.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-11-08 15:41:18 +01:00
parent c20a1089a9
commit 5fb64e12e1
12 changed files with 344 additions and 41 deletions

View File

@@ -307,6 +307,57 @@ namespace MalachScript::Parser {
TOperator _operator;
std::unique_ptr<const ParsedStatement> _rightHand;
};
class ParsedVoidStatement : public ParsedStatementImpl<ParsedStatementKind::Void> {
public:
ParsedVoidStatement(const TextSpan& span) : ParsedStatementImpl(span) {}
};
template <class T> class ParsedLiteralStatement : public ParsedStatementImpl<ParsedStatementKind::Literal> {
public:
ParsedLiteralStatement(const TextSpan& span, T literalValue)
: ParsedStatementImpl(span), _literalValue(literalValue) {}
[[nodiscard]] inline const T& GetLiteralValue() const noexcept { return _literalValue; }
private:
T _literalValue;
};
class ParsedReturnStatement : public ParsedStatementImpl<ParsedStatementKind::Return>{
public:
ParsedReturnStatement(const TextSpan& span, const ParsedStatement* statement)
: ParsedStatementImpl(span), _statement(statement) {}
private:
std::unique_ptr<const ParsedStatement> _statement;
};
class ParsedVarAccessStatement : public ParsedStatementImpl<ParsedStatementKind::VarAccess>{
public:
ParsedVarAccessStatement(const TextSpan& span, std::vector<Identifier> scope)
: ParsedStatementImpl(span), _scope(std::move(scope)) {}
private:
std::vector<Identifier> _scope;
};
class ParsedIncrementStatement : public ParsedStatementImpl<ParsedStatementKind::Increment>{
public:
ParsedIncrementStatement(const TextSpan& span, const ParsedStatement* statement)
: ParsedStatementImpl(span), _statement(statement) {}
private:
std::unique_ptr<const ParsedStatement> _statement;
};
class ParsedDecrementStatement : public ParsedStatementImpl<ParsedStatementKind::Decrement>{
public:
ParsedDecrementStatement(const TextSpan& span, const ParsedStatement* statement)
: ParsedStatementImpl(span), _statement(statement) {}
private:
std::unique_ptr<const ParsedStatement> _statement;
};
}
#endif // MALACHSCRIPT_PARSEDSTATEMENT_HPP