Skip to content

Conversation

@wolfv
Copy link
Member

@wolfv wolfv commented Sep 16, 2024

I tried to implement support for expressions such as $((1 + 5)). Didn't really make it work all the way though.

evaluate_word_parts_inner(parts, false, state, stdin, stderr)
}

fn evaluate_arithmetic_expression(expr: ArithmeticExpr, state: &ShellState) -> Result<i64, String> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this considers precedence?

@prsabahrami
Copy link
Contributor

This gets somewhat complicated. I have taken this down another path and started implementing that. We also should use Pratt Parsing in Pest to handle op precedence. I have created another WIP PR #147. I'll try to add some comments to make it easier to read. Overall, it is doable, but take a look at #147 and let me know what you think! I'll try to finish this by tomorrow and see if it works. I think the way I have implemented the other one makes it much easier to handle handle for and while too!

@wolfv wolfv closed this Sep 18, 2024
@wolfv wolfv deleted the arithmetic branch September 21, 2024 07:33
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.

3 participants