-
Notifications
You must be signed in to change notification settings - Fork 42
Fix eval function call #47
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
Merged
Merged
+7,718
−5,783
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In this commit, we rename the parser functions, changed the order of the declarations (to simplify program comprehension), and also improve the parser test organization. To this end, we moved the test suite to the 'tests/parser_tests.rs' file. New features in the parse: - parse for statement - parse while statement
…er_expr, parser_stmt) Also, since we aim to make the code more correct, we decided to remove the code related to the statement 'match-case'.
…sions and a checker for statements.
…variables - Update Environment to differentiate mutable and non-mutable variables: - Add mutable flag to variable storage in Scope - Update lookup to return (bool, Type) tuple indicating mutability - Modify map_variable to require mutability parameter - Add type checking for new statements: - val declaration (non-mutable) - var declaration (mutable) - if-then-else with proper type checking - for loops with type checking - while loops with type checking - Update test suite: - Add tests for mutable/non-mutable variable behavior - Add tests for new statement type checking - Fix existing tests to declare variables before assignment - Clean up source code: - Remove old type checker files (tc/*) - Reorganize type checking logic - Improve error messages
- Split interpreter.rs into expression_eval.rs and statement_execute.rs - Moved expression evaluation logic into expression_eval.rs - Moved statement execution logic into statement_execute.rs - Created mod.rs to expose the main functions (eval, run, execute) - Removed the old interpreter.rs file - Fixed unused import warning in statement_execute.rs - All tests pass successfully
… expression tests - Add missing NEQ (!=) operator implementation in expression evaluator - Create relational_expression_tests module with 40 comprehensive tests - Cover all relational operators: EQ, NEQ, GT, LT, GTE, LTE - Test integer, real, and mixed type comparisons - Include edge cases: negatives, zero, decimals, large numbers - Add error handling tests for invalid types and undefined variables - Test complex expressions with variables and arithmetic operations - Maintain proper test organization in expression_eval.rs
…t cases - Create boolean_expression_tests module in expression_eval.rs - Cover all boolean operators: AND, OR, NOT with truth table tests - Test basic operations: all combinations of True/False for AND/OR - Test NOT operator with both True and False inputs - Add variable integration tests with boolean values - Test nested boolean expressions and operator precedence - Include complex expressions combining boolean, relational, and arithmetic - Test De Morgan's law equivalence verification - Add edge cases: double negation, chained operators - Test integration with relational operators (>, <, ==, etc.) - Include error handling for invalid types (integers, strings, reals) - Test undefined variable handling in boolean contexts - Verify proper evaluation order in mixed expressions - Add comprehensive operator chaining tests - Maintain consistent test organization alongside existing modules
- Rename all eval function calls to use consistent 'eval_' prefix: * add → eval_add, sub → eval_sub, mul → eval_mul, div → eval_div * and → eval_and, or → eval_or, not → eval_not * eq → eval_eq, neq → eval_neq, gt → eval_gt, lt → eval_lt * gte → eval_gte, lte → eval_lte * lookup → eval_lookup, call → eval_call - Reorganize function definitions to match eval() function call order - Move helper functions (eval_binary_arith_op, eval_binary_boolean_op, eval_binary_rel_op) before their usage - Group functions by operation type: arithmetic, boolean, relational - Maintain all existing functionality and test coverage - Improve code organization and naming consistency
…I and error handling
Collaborator
|
hard to follow this rhythm. plz teach me how to |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Redesign of the function call evaluation and interpreter environment.