mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-05 22:48:43 +00:00
replace executor, task namespace: utils -> core
This commit is contained in:
parent
4bf3406892
commit
331d97ab48
9 changed files with 37 additions and 45 deletions
|
|
@ -20,7 +20,7 @@ struct State {
|
|||
|
||||
//
|
||||
|
||||
using Executor = utils::Executor<Exprs, Types, Names, State, Positions>;
|
||||
using Executor = core::Executor<Exprs, Types, Names, State, Positions>;
|
||||
|
||||
using ParserNode = parser::ParseTree::Node;
|
||||
|
||||
|
|
@ -31,9 +31,9 @@ struct Args {
|
|||
};
|
||||
|
||||
template <typename N>
|
||||
using Task = utils::Task<Executor, N, Args, parser::ParseTree::Node>;
|
||||
using Task = core::Task<Executor, N, Args, parser::ParseTree::Node>;
|
||||
|
||||
template <typename N, typename Tag = utils::None> struct BuilderTask {
|
||||
template <typename N, typename Tag = core::None> struct BuilderTask {
|
||||
static_assert(false);
|
||||
};
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ template <typename N> struct BuilderTaskUtils : public Task<N> {
|
|||
}
|
||||
|
||||
// TODO: rename
|
||||
template <typename OtherN, typename OtherTag = utils::None,
|
||||
template <typename OtherN, typename OtherTag = core::None,
|
||||
typename Ret = OtherN>
|
||||
Ret RunOther(const parser::ParseTree::Node &node, const Args &args = {}) {
|
||||
BuilderTask<OtherN, OtherTag> task(this->executor);
|
||||
|
|
@ -75,7 +75,7 @@ template <typename N> struct BuilderTaskUtils : public Task<N> {
|
|||
template <typename N> struct BasicBuilderTaskBase : public BuilderTaskUtils<N> {
|
||||
using BuilderTaskUtils<N>::BuilderTaskUtils;
|
||||
|
||||
template <typename OtherN, typename OtherTag = utils::None,
|
||||
template <typename OtherN, typename OtherTag = core::None,
|
||||
typename Ret = OtherN>
|
||||
Ret Run(const parser::ParseTree::Node &node, const Args &args = {}) {
|
||||
BuilderTask<OtherN, OtherTag> task(this->executor);
|
||||
|
|
@ -87,7 +87,7 @@ template <typename N>
|
|||
struct ExprBuilderTaskBase : public BuilderTaskUtils<Node> {
|
||||
using BuilderTaskUtils<Node>::BuilderTaskUtils;
|
||||
|
||||
template <typename OtherN, typename OtherTag = utils::None,
|
||||
template <typename OtherN, typename OtherTag = core::None,
|
||||
typename Ret = Node>
|
||||
Ret Run(const parser::ParseTree::Node &node, const Args &args = {}) {
|
||||
BuilderTask<OtherN, OtherTag> task(this->executor);
|
||||
|
|
@ -99,7 +99,7 @@ template <typename N>
|
|||
struct TypeBuilderTaskBase : public BuilderTaskUtils<nodes::Type> {
|
||||
using BuilderTaskUtils<nodes::Type>::BuilderTaskUtils;
|
||||
|
||||
template <typename OtherN, typename OtherTag = utils::None,
|
||||
template <typename OtherN, typename OtherTag = core::None,
|
||||
typename Ret = nodes::Type>
|
||||
Ret Run(const parser::ParseTree::Node &node, const Args &args = {}) {
|
||||
BuilderTask<OtherN, OtherTag> task(this->executor);
|
||||
|
|
@ -111,7 +111,7 @@ template <typename N>
|
|||
struct StatementBuilderTaskBase : public BuilderTaskUtils<N> {
|
||||
using BuilderTaskUtils<N>::BuilderTaskUtils;
|
||||
|
||||
template <typename OtherN, typename OtherTag = utils::None,
|
||||
template <typename OtherN, typename OtherTag = core::None,
|
||||
typename Ret = OtherN>
|
||||
Ret Run(const parser::ParseTree::Node &node, const Args &args = {}) {
|
||||
BuilderTask<OtherN, OtherTag> task(this->executor);
|
||||
|
|
|
|||
|
|
@ -180,8 +180,8 @@ struct BuilderTask<nodes::ModifierExpression, T>
|
|||
|
||||
return Build(
|
||||
nodes::ModifierExpression{
|
||||
.modifier = RunOther<nodes::Modifier, utils::None, nodes::Modifier>(
|
||||
parser_node.nth_child(modifier_pos)),
|
||||
.modifier =
|
||||
RunOther<nodes::Modifier>(parser_node.nth_child(modifier_pos)),
|
||||
.expr = Run<Node>(parser_node.nth_named_child(0)),
|
||||
},
|
||||
parser_node.get_pos());
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "type_builders.hpp"
|
||||
#include "type_nodes.hpp"
|
||||
|
||||
// TODO: insert is_scoped everywere
|
||||
// TODO: insert is_scoped assignment everywere
|
||||
|
||||
namespace builders {
|
||||
|
||||
|
|
@ -134,10 +134,9 @@ Node BuilderTask<Node>::operator()(const ParserNode &parser_node,
|
|||
return Build(RunOther<nodes::Literal, nodes::null>(parser_node),
|
||||
parser_node.get_pos());
|
||||
case tokens::Type::EXTRA:
|
||||
return Build(RunOther<nodes::Extra, utils::None>(parser_node),
|
||||
parser_node.get_pos());
|
||||
return Build(RunOther<nodes::Extra>(parser_node), parser_node.get_pos());
|
||||
case tokens::Type::EMPTY_LINES:
|
||||
return Build(RunOther<nodes::EmptyLines, utils::None>(parser_node),
|
||||
return Build(RunOther<nodes::EmptyLines>(parser_node),
|
||||
parser_node.get_pos());
|
||||
default:
|
||||
break;
|
||||
|
|
@ -370,8 +369,7 @@ Node BuilderTask<nodes::NameDefinition>::operator()(
|
|||
.kind = (modifier == "%" || modifier == "let")
|
||||
? nodes::NameDefinition::LET
|
||||
: nodes::NameDefinition::VAR,
|
||||
.name =
|
||||
Run<nodes::Identifier, utils::None, nodes::Identifier>(name_node),
|
||||
.name = RunOther<nodes::Identifier>(name_node),
|
||||
},
|
||||
parser_node.get_pos());
|
||||
} // IN PROGRESS
|
||||
|
|
@ -487,8 +485,7 @@ Node BuilderTask<nodes::NameExpression, utils::FuncCallTag>::operator()(
|
|||
.name = RunOther<nodes::Identifier>(name_node),
|
||||
.args = std::move(args),
|
||||
.prefix = prefix_node.has_value()
|
||||
? RunOther<nodes::Type, utils::None, nodes::Type>(
|
||||
prefix_node.value())
|
||||
? RunOther<nodes::Type>(prefix_node.value())
|
||||
: nodes::MaybeType(),
|
||||
.is_point_call = is_point_call,
|
||||
.is_operator_call = false,
|
||||
|
|
@ -512,8 +509,8 @@ Node BuilderTask<nodes::Constructor>::operator()(const ParserNode &parser_node,
|
|||
|
||||
return Build(
|
||||
nodes::Constructor{
|
||||
.type = RunOther<nodes::Type, utils::None, nodes::Type>(
|
||||
parser_node.child_by_field_name("type")),
|
||||
.type =
|
||||
RunOther<nodes::Type>(parser_node.child_by_field_name("type")),
|
||||
.args = std::move(args),
|
||||
},
|
||||
parser_node.get_pos());
|
||||
|
|
|
|||
|
|
@ -239,10 +239,9 @@ BuilderTask<nodes::TypeDefinition>::operator()(const ParserNode &parser_node,
|
|||
}
|
||||
}
|
||||
|
||||
nodes::MaybeType type =
|
||||
type_node.has_value()
|
||||
? RunOther<nodes::Type, utils::None, nodes::Type>(type_node.value())
|
||||
: nodes::MaybeType();
|
||||
nodes::MaybeType type = type_node.has_value()
|
||||
? RunOther<nodes::Type>(type_node.value())
|
||||
: nodes::MaybeType();
|
||||
|
||||
std::unordered_set<std::string> annotations;
|
||||
|
||||
|
|
@ -378,14 +377,12 @@ nodes::FunctionDefinition BuilderTask<nodes::FunctionDefinition>::operator()(
|
|||
case tokens::Type::SIMPLE_TYPE:
|
||||
if (current_type_id >= args.size()) {
|
||||
args.push_back(nodes::FunctionDefinition::Argument(
|
||||
last_annotation,
|
||||
RunOther<nodes::Type, utils::None, nodes::Type>(current_node),
|
||||
last_annotation, RunOther<nodes::Type>(current_node),
|
||||
last_before_modifier));
|
||||
} else {
|
||||
if (!args[current_type_id].add_type(
|
||||
last_annotation,
|
||||
RunOther<nodes::Type, utils::None, nodes::Type>(current_node),
|
||||
last_before_modifier)) {
|
||||
if (!args[current_type_id].add_type(last_annotation,
|
||||
RunOther<nodes::Type>(current_node),
|
||||
last_before_modifier)) {
|
||||
logc.Fatal<Log::kProc>(
|
||||
{{"It is impossible to use argument modifiers (annotations, "
|
||||
"references, "
|
||||
|
|
|
|||
|
|
@ -103,9 +103,7 @@ nodes::Type BuilderTask<nodes::Type, TypeTag<Tp::REFERENCE_TYPE>>::operator()(
|
|||
Log::Context logc(executor.log(), Log::Area::kParse);
|
||||
|
||||
nodes::Type type = Run<nodes::Type>(parser_node.nth_named_child(0));
|
||||
type.get()->set_modifier(
|
||||
RunOther<nodes::Modifier, utils::None, nodes::Modifier>(
|
||||
parser_node.nth_child(0)));
|
||||
type.get()->set_modifier(RunOther<nodes::Modifier>(parser_node.nth_child(0)));
|
||||
return type;
|
||||
}
|
||||
|
||||
|
|
@ -117,9 +115,8 @@ nodes::Type BuilderTask<nodes::Type, TypeTag<Tp::MODIFIED_TYPE>>::operator()(
|
|||
std::vector<nodes::Type> parameters;
|
||||
parameters.push_back(Run<nodes::Type>(parser_node.nth_named_child(0)));
|
||||
|
||||
nodes::Modifier modifier =
|
||||
RunOther<nodes::Modifier, utils::None, nodes::Modifier>(
|
||||
parser_node.nth_child(parser_node.child_count() - 1));
|
||||
nodes::Modifier modifier = RunOther<nodes::Modifier>(
|
||||
parser_node.nth_child(parser_node.child_count() - 1));
|
||||
|
||||
std::string identifier;
|
||||
|
||||
|
|
@ -153,8 +150,7 @@ nodes::Type BuilderTask<nodes::Type, TypeTag<Tp::SIMPLE_TYPE>>::operator()(
|
|||
collect_parameters(name_node.next_named_sibling(), executor);
|
||||
|
||||
return executor.state<Types>().add_type(nodes::TypeData(
|
||||
RunOther<nodes::Identifier, utils::None, nodes::Identifier>(name_node),
|
||||
std::move(parameters)));
|
||||
RunOther<nodes::Identifier>(name_node), std::move(parameters)));
|
||||
}
|
||||
|
||||
} // namespace builders
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ private:
|
|||
|
||||
using Exprs = nodes::NodeStorage; // nodes::ExprStorage;
|
||||
|
||||
using Executor = utils::Executor<Exprs, Printer>;
|
||||
using Executor = core::Executor<Exprs, Printer>;
|
||||
|
||||
using Node = nodes::Node_<>;
|
||||
|
||||
|
|
@ -134,9 +134,9 @@ struct Args {
|
|||
bool const_is_none = false;
|
||||
};
|
||||
|
||||
using Result = utils::None;
|
||||
using Result = core::None;
|
||||
|
||||
template <typename N> using Task = utils::Task<Executor, Result, Args, N>;
|
||||
template <typename N> using Task = core::Task<Executor, Result, Args, N>;
|
||||
|
||||
template <typename N> struct PrintTask {
|
||||
static_assert(false);
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ using Types = nodes::TypeStorage;
|
|||
using Names = names::NameTree;
|
||||
using Positions = core::DependentStorage<utils::Pos>;
|
||||
|
||||
using Executor = utils::Executor<Exprs, Types, Names, State, Positions>;
|
||||
using Executor = core::Executor<Exprs, Types, Names, State, Positions>;
|
||||
|
||||
using Node = nodes::Node_<nodes::NodePart<utils::Pos>>;
|
||||
|
||||
|
|
@ -350,7 +350,7 @@ void type_check_error(const std::string &message, const utils::Pos &pos,
|
|||
|
||||
//
|
||||
|
||||
template <typename N> using Task = utils::Task<Executor, Result, Args, N>;
|
||||
template <typename N> using Task = core::Task<Executor, Result, Args, N>;
|
||||
|
||||
template <typename N> struct CheckTask {
|
||||
static_assert(false);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "log.hpp"
|
||||
|
||||
namespace utils {
|
||||
namespace core {
|
||||
|
||||
struct None {};
|
||||
|
||||
|
|
@ -74,4 +74,4 @@ public:
|
|||
Exec &executor;
|
||||
};
|
||||
|
||||
} // namespace utils
|
||||
} // namespace core
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
#include "executor.hpp"
|
||||
|
||||
namespace core {} // namespace core
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue