mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-26 16:58:45 +00:00
Revert "changes for new grammar, fixes"
This reverts commit f912cdac41.
This commit is contained in:
parent
f912cdac41
commit
03dea59d33
10 changed files with 5 additions and 59 deletions
|
|
@ -167,14 +167,6 @@ void BuildVisitor::Visit(VariableDefinitionStatement* node) {
|
|||
// error
|
||||
}
|
||||
|
||||
size_t child_count = parse_node.NamedChildCount();
|
||||
|
||||
if (child_count > 2) { // name, value [, in_expression]
|
||||
current_node_ = parse_node.ChildByFieldName("in_expression");
|
||||
node->in_expression.emplace();
|
||||
Visit(node->in_expression.value());
|
||||
}
|
||||
|
||||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,22 +47,11 @@ void ExecuteVisitor::Visit(AliasDefinitionStatement* node) {
|
|||
}
|
||||
|
||||
void ExecuteVisitor::Visit(VariableDefinitionStatement* node) {
|
||||
// TODO: optional variable definitions
|
||||
|
||||
if (node->in_expression.has_value()) {
|
||||
context_manager_.EnterContext();
|
||||
}
|
||||
|
||||
Visitor::Visit(node->value);
|
||||
|
||||
is_const_definition_ = node->modifier;
|
||||
Visitor::Visit(node->name); // current_type_ passed from value
|
||||
is_const_definition_ = std::nullopt;
|
||||
|
||||
if (node->in_expression.has_value()) {
|
||||
Visitor::Visit(node->in_expression.value());
|
||||
context_manager_.ExitContext();
|
||||
}
|
||||
}
|
||||
|
||||
void ExecuteVisitor::Visit(FunctionDeclaration* node) {
|
||||
|
|
|
|||
|
|
@ -93,12 +93,6 @@ void PrintVisitor::Visit(VariableDefinitionStatement* node) {
|
|||
Visitor::Visit(node->name);
|
||||
out_ << "] = (";
|
||||
Visitor::Visit(node->value);
|
||||
|
||||
if (node->in_expression.has_value()) {
|
||||
out_ << ") in (";
|
||||
Visitor::Visit(node->in_expression.value());
|
||||
}
|
||||
|
||||
out_ << ")\n";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,11 +101,7 @@ void TypeCheckVisitor::Visit(AliasDefinitionStatement* node) {
|
|||
|
||||
// TODO: move, etc.
|
||||
void TypeCheckVisitor::Visit(VariableDefinitionStatement* node) {
|
||||
// TODO: optional variable definitions
|
||||
|
||||
if (node->in_expression.has_value()) {
|
||||
context_manager_.EnterContext();
|
||||
}
|
||||
is_in_statement_ = true;
|
||||
|
||||
Visitor::Visit(node->value);
|
||||
// current_type from value automatically passed to name definitions
|
||||
|
|
@ -114,12 +110,8 @@ void TypeCheckVisitor::Visit(VariableDefinitionStatement* node) {
|
|||
Visitor::Visit(node->name);
|
||||
is_const_definition_ = std::nullopt;
|
||||
|
||||
if (node->in_expression.has_value()) {
|
||||
Visitor::Visit(node->in_expression.value());
|
||||
context_manager_.ExitContext();
|
||||
}
|
||||
|
||||
current_type_ = internal_to_abstract_type_.at(info::type::InternalType::Unit);
|
||||
is_in_statement_ = false;
|
||||
|
||||
node->base.type_ = current_type_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,12 +123,6 @@ void TypedPrintVisitor::Visit(VariableDefinitionStatement* node) {
|
|||
Visitor::Visit(node->name);
|
||||
out_ << "] = (";
|
||||
Visitor::Visit(node->value);
|
||||
|
||||
if (node->in_expression.has_value()) {
|
||||
out_ << ") in (";
|
||||
Visitor::Visit(node->in_expression.value());
|
||||
}
|
||||
|
||||
out_ << ")\n";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -328,9 +328,6 @@ void Visitor::Visit(AliasDefinitionStatement* node) {
|
|||
void Visitor::Visit(VariableDefinitionStatement* node) {
|
||||
Visit(node->name);
|
||||
Visit(node->value);
|
||||
if (node->in_expression.has_value()) {
|
||||
Visit(node->in_expression.value());
|
||||
}
|
||||
}
|
||||
|
||||
void Visitor::Visit(FunctionDeclaration* node) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue