New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add 闭环 #47
add 闭环 #47
Conversation
flaneur2020
commented
Apr 24, 2021
•
edited
edited
- add token about the 闭环 and lexer
- add parser about the 闭环 statement
- refactor: take reference instead of move on iterating the ast nodes
- add the interpreter logic about the 闭环 statement
- support 破圈(break) statement (maybe we could implement it in another PR)
src/evaluator/mod.rs
Outdated
None => return None, | ||
}; | ||
|
||
while Self::is_truthy(cond.clone()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused about this logic, cond
is immutable, so we have an infinite loop when it evaluates to true
, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it's a bug, maybe it'd been fixed on my latest commit
BTW, please add some unit tests for this feature. |
thank your for remind, i've add some test cases about this, please check again 🤝 |
LGTM |
@@ -321,13 +325,35 @@ impl Evaluator { | |||
} | |||
} | |||
|
|||
fn eval_call_expr(&mut self, func: Box<Expr>, args: Vec<Expr>) -> Object { | |||
fn eval_while_expr( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
解 Box 好啊!clippy 总跟我叨叨。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qwq!