mirror of
https://codeberg.org/ProgramSnail/lang_2023.git
synced 2025-12-08 07:58:44 +00:00
fixes , constructor patter fix, for loop fix
This commit is contained in:
parent
6ba31969d2
commit
70b84c38f0
7 changed files with 33 additions and 49 deletions
|
|
@ -504,7 +504,7 @@ void BuildVisitor::Visit(TypeConstructorPattern* node) {
|
|||
}
|
||||
|
||||
|
||||
void BuildVisitor::Visit(PatternToken& node) {
|
||||
void BuildVisitor::Visit(Pattern& node) { // <-> ScopedPattern
|
||||
auto parse_node = current_node_;
|
||||
|
||||
current_node_ = parse_node.NthNamedChild(0);
|
||||
|
|
@ -527,26 +527,6 @@ void BuildVisitor::Visit(PatternToken& node) {
|
|||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
void BuildVisitor::Visit(Pattern& node) {
|
||||
auto parse_node = current_node_;
|
||||
|
||||
current_node_ = parse_node.NthNamedChild(0);
|
||||
|
||||
std::string current_node_type = current_node_.GetType();
|
||||
|
||||
if (current_node_type == parser::tokens::TypeConstructorPattern) { // optimize ??
|
||||
node = std::make_unique<TypeConstructorPattern>();
|
||||
Visit(std::get<std::unique_ptr<TypeConstructorPattern>>(node).get());
|
||||
} else if (current_node_type == parser::tokens::PatternToken) {
|
||||
node = std::make_unique<PatternToken>();
|
||||
Visit(*std::get<std::unique_ptr<PatternToken>>(node));
|
||||
} else {
|
||||
// error
|
||||
}
|
||||
|
||||
current_node_ = parse_node;
|
||||
}
|
||||
|
||||
void BuildVisitor::Visit(MatchCase* node) {
|
||||
SetPosition(node->base, current_node_);
|
||||
|
||||
|
|
@ -653,6 +633,13 @@ void BuildVisitor::Visit(ForLoop* node) {
|
|||
|
||||
auto parse_node = current_node_;
|
||||
|
||||
std::string modifier = parse_node.NthChild(1).GetValue();
|
||||
if (modifier == "const") {
|
||||
node->variable_modifier = utils::IsConstModifier::Const;
|
||||
} else if (modifier == "var") {
|
||||
node->variable_modifier = utils::IsConstModifier::Var;
|
||||
}
|
||||
|
||||
current_node_ = parse_node.ChildByFieldName("variable");
|
||||
Visit(node->variable);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue