mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-06 06: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
|
|
@ -307,7 +307,6 @@ struct VariableDefinitionStatement {
|
|||
utils::AssignmentModifier assignment_modifier;
|
||||
AnyName name;
|
||||
SuperExpression value;
|
||||
std::optional<SuperExpression> in_expression;
|
||||
};
|
||||
|
||||
struct FunctionDeclaration {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit ab391d2d8d5251422abc94b80a51438faddb19c7
|
||||
Subproject commit 24bcf6e960957daf5662b764480f1d56637b1712
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -106,10 +106,10 @@ namespace var \div {
|
|||
|
||||
typeclass \eq =
|
||||
& var ( == ) : \eq -> \bool
|
||||
& var ( <> ) : \eq -> \bool
|
||||
& var ( != ) : \eq -> \bool
|
||||
|
||||
namespace var \eq {
|
||||
def ( <> ) : x = not: (self == x)
|
||||
def ( != ) : x = not: (self == x)
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
decl test-variables : \int -> \unit
|
||||
def test-variables : a = {
|
||||
var x = if a < 123 then "aaa" else "bbb"
|
||||
|
||||
var y = 543.32 in do-something:
|
||||
|
||||
var z = 543.32 in {
|
||||
for x in 1--10 do print: 111
|
||||
if scan:[int] < 11 then do-something-another: z "aaa"
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue