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

Separate parsing and evaluation in arithmetic expansion #178

Merged
merged 21 commits into from
Aug 8, 2022
Merged

Conversation

magicant
Copy link
Owner

@magicant magicant commented Jul 31, 2022

This pull request refactors the arithmetic expansion implementation.

Previously, We performed syntax parsing and evaluation in a single pass. This PR splits them into separate processes.

The motivation for this refactoring comes from the difficulty in implementing and testing the evaluation Mode. To implement conditional evaluation required by the ||, &&, and ? : operator, we need to conditionally skip evaluation of part of the expression and prevent any side effects. We used the Mode flag to indicate the condition to trigger skipping, but we still need to parse the whole expression syntax regardless of the flag. That was making the implementation complicated and hard to understand.

By separating the parser from evaluation, skipping evaluation can be coded much more intuitively just by not calling the evaluation function.

@magicant magicant marked this pull request as ready for review August 7, 2022 03:09
@magicant magicant merged commit dcdd26f into master Aug 8, 2022
@magicant magicant deleted the arith_ast branch August 8, 2022 12:50
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

1 participant