-
Notifications
You must be signed in to change notification settings - Fork 0
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
Issue 175: Added Support for Arrays (1D) #183
Merged
Merged
Conversation
This file contains 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
- Rearranged sequence of logic to fix this, since `-` would indicate a number previously #175
- Restructured `assignment` node in `ASTNode` to have `lhs` & `rhs` #175
- Looking through the debugging output for the lexer, I realized that negative numbers were being tokenized as `-` followed by the positive version of the number. - Updated `scan_array` to detect and correctly handle negative numbers (`-`) within array slices, ensuring that `-1` is tokenized as a single `TOKEN_INTEGER` instead of separate tokens for `-` and `1`. - Modified `scan_number` to construct lexemes for negative numbers properly, including the `-` sign. - Added conditions to differentiate between negative numbers and array operators (`^-`, `-^`) based on context. - Included debug statements to verify lexeme capture during tokenization. - Verified fixes with test cases for array slicing scenarios, including `[::-1]`, `[-5:-1:2]`, and mixed positive/negative indices. - These changes now resolves issues where the lexer misinterpreted `-` in slices, leading to parsing errors like "Expected expression (found `-`)." #175
…on't memory crash #175
- Refactored `ASTNode` to separate fields for distinct node types, preventing memory conflicts. - Updated parser functions to use correct `ASTNodeType` for declarations and assignments. - Fixed crash in `print_ast` caused by uninitialized or overlapping fields. - Ensured proper memory initialization using calloc for zero-initialized nodes. - Enhanced debugging and error handling for better resilience against invalid memory access. #175
…INT_SIZE` respectively #175
- Fixed `array[::-1]` returning empty array by correcting `end_index` logic for negative steps. - Enhanced debug logs for slicing operations. #175
- Prevented mutations on constant arrays by preserving the `is_constant` flag in `add_variable`. - Enhanced `get_variable` to correctly handle and debug `TYPE_ARRAY` variables. - Refactored `interpret_assignment` to delegate array operations to `interpret_array_operation` for consistent immutability enforcement. - Verified fixes with test scripts and added debug logs for better diagnostics. #175
- Fixed by passing correct node (`lhs_node`) to `interpret_array_operation` in `interpret_assigment`. #175
This reverts commit e38246f.
4 tasks
KennyOliver
added
documentation
Improvements or additions to documentation
enhancement
New feature or request
labels
Jan 8, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
#175