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.
Description
This pull request introduces support for unsized and partially-unsized array initializers, including multi-dimensional arrays, in both the parser and the interpreter. It also adds new test cases to verify these features and refactors array access handling in the codebase. The most important changes are grouped below:
Parser and Language Support for Array Initializers:
arr[] = {...}) and partially-unsized (arr[][N] = {...}) array declarations, inferring the first dimension from the initializer length or from trailing dimensions as needed. (lang.y) [1] [2]lang.y)Interpreter/Core Refactoring for Array Access:
node->data.array.nameinstead ofnode->data.name, ensuring correct handling of array variables in type checks and assignments. (ast.c) [1] [2]is_short_expression,is_float_expression, andis_double_expressionfunctions, with error reporting for undefined variables. (ast.c) [1] [2] [3]Short-Circuit Logical Evaluation:
evaluate_expression_intandevaluate_expression_boolto implement proper short-circuit evaluation forANDandORoperations. (ast.c) [1] [2]Test Cases for Array Initializers and BFS:
test_cases/unsized_array_init.brainrot,test_cases/unsized_array_complex.brainrot,test_cases/matrix_init_simple.brainrot,test_cases/matrix_init_probe.brainrot,test_cases/grid_bfs.brainrot,test_cases/grid_bfs_1d.brainrot) [1] [2] [3] [4] [5] [6]Test Result Updates:
tests/expected_results.jsonto include expected outputs for the new test cases. (tests/expected_results.json)Related Issue
this PR fix the limitation we had from #135
Type of Change
Checklist