This commit is contained in:
2026-05-17 02:32:41 +02:00
parent 50c98cf5f7
commit bfaaa4006b
2 changed files with 23 additions and 21 deletions
+2
View File
@@ -12,4 +12,6 @@ void main() {
app_instance.boot();
app_instance.run();
1+(1*2);
}
+21 -21
View File
@@ -156,6 +156,25 @@ impl GetRust for Expression {
+ &Some(prefixes).get_rust()
+ &postfixes.get_rust()
}
// Safely integrated to handle the tree structure built by the Pratt Parser
Expression::Binary { lhs, op, rhs } => {
let op_str = match op {
BinaryOp::Plus => "+",
BinaryOp::Minus => "-",
BinaryOp::Multiply => "*",
BinaryOp::Divide => "/",
BinaryOp::Modulo => "%",
BinaryOp::Equal => "==",
BinaryOp::NotEqual => "!=",
BinaryOp::LessThan => "<",
BinaryOp::GreaterThan => ">",
BinaryOp::LessThanOrEqual => "<=",
BinaryOp::GreaterThanOrEqual => ">=",
BinaryOp::And => "&&",
BinaryOp::Or => "||",
};
format!("{} {} {}", lhs.get_rust(), op_str, rhs.get_rust())
}
}
}
}
@@ -225,26 +244,8 @@ impl GetRust for Postfix {
Postfix::Index(idx) => {
format!("[{}]", idx.get_rust())
}
Postfix::Binary(op, rhs) => {
let op_str = match op {
BinaryOp::Plus => "+",
BinaryOp::Minus => "-",
BinaryOp::Multiply => "*",
BinaryOp::Divide => "/",
BinaryOp::Modulo => "%",
BinaryOp::Equal => "==",
BinaryOp::NotEqual => "!=",
BinaryOp::LessThan => "<",
BinaryOp::GreaterThan => ">",
BinaryOp::LessThanOrEqual => "<=",
BinaryOp::GreaterThanOrEqual => ">=",
BinaryOp::And => "&&",
BinaryOp::Or => "||",
};
format!(" {} {}", op_str, rhs.get_rust())
}
} // Note: Postfix::Binary variant logic has been completely transferred
// to Expression::Binary to match your updated AST configuration.
}
}
}
@@ -254,7 +255,6 @@ impl GetRust for [Postfix] {
self.iter().map(Postfix::get_rust).collect()
}
}
// ---------------------------------------------------------------------------
// ToRust — output-writing (top-level, statements, blocks)
// ---------------------------------------------------------------------------