Skip to content
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

Merged
merged 6 commits into from Apr 25, 2021
Merged

add 闭环 #47

merged 6 commits into from Apr 25, 2021

Conversation

flaneur2020
Copy link
Owner

@flaneur2020 flaneur2020 commented Apr 24, 2021

  • 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)

None => return None,
};

while Self::is_truthy(cond.clone()) {
Copy link
Collaborator

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 ?

Copy link
Owner Author

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

@chenhengqi
Copy link
Collaborator

BTW, please add some unit tests for this feature.

@flaneur2020
Copy link
Owner Author

BTW, please add some unit tests for this feature.

thank your for remind, i've add some test cases about this, please check again 🤝

@flaneur2020 flaneur2020 changed the title WIP: add 闭环 add 闭环 Apr 24, 2021
@chenhengqi
Copy link
Collaborator

LGTM

@@ -321,13 +325,35 @@ impl Evaluator {
}
}

fn eval_call_expr(&mut self, func: Box<Expr>, args: Vec<Expr>) -> Object {
fn eval_while_expr(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

解 Box 好啊!clippy 总跟我叨叨。

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

qwq!

@flaneur2020 flaneur2020 merged commit d60eefa into master Apr 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants