Renames project.

This commit is contained in:
2020-10-05 17:45:00 +02:00
parent 125bb8459c
commit f299d5183f
23 changed files with 197 additions and 67 deletions

View File

@@ -0,0 +1,51 @@
#ifndef MALACHSCRIPT_PARSEDSTATEMENT_HPP
#define MALACHSCRIPT_PARSEDSTATEMENT_HPP
#include <vector>
#include "../../TextSpan.hpp"
#include "ParsedStatementKind.hpp"
namespace MalachScript::Parser {
class ParsedStatement {
TextSpan _span;
public:
ParsedStatement(TextSpan span) : _span(span) {}
[[nodiscard]] virtual ParsedStatementKind GetKind() const noexcept = 0;
[[nodiscard]] inline const TextSpan& GetSpan() const noexcept { return _span; }
};
template <ParsedStatementKind kind> class ParsedStatementImpl : public ParsedStatement {
public:
ParsedStatementImpl(TextSpan span) : ParsedStatement(span) {}
[[nodiscard]] inline ParsedStatementKind GetKind() const noexcept override { return kind; }
};
class ParsedBlockStatement : public ParsedStatementImpl<ParsedStatementKind::Block> {
std::vector<std::unique_ptr<const ParsedStatement>> _statements;
public:
ParsedBlockStatement(TextSpan span, const std::vector<const ParsedStatement*>& statements)
: ParsedStatementImpl<ParsedStatementKind::Block>(span), _statements(statements.size()) {
for (size_t i = 0; i < statements.size(); i++)
_statements[i] = std::unique_ptr<const ParsedStatement>(statements[i]);
}
[[nodiscard]] inline const std::vector<std::unique_ptr<const ParsedStatement>>& GetStatements() const noexcept {
return _statements;
}
};
class ParsedScriptStatement : public ParsedStatementImpl<ParsedStatementKind::Script> {
std::unique_ptr<const ParsedBlockStatement> _block;
public:
ParsedScriptStatement(const ParsedBlockStatement* block)
: ParsedStatementImpl<ParsedStatementKind::Script>(block->GetSpan()), _block(block) {}
[[nodiscard]] inline const std::unique_ptr<const ParsedBlockStatement>& GetBlock() const noexcept {
return _block;
}
};
}
#endif // MALACHSCRIPT_PARSEDSTATEMENT_HPP