Merged
Conversation
Add indexed array support:
- Array literal assignment: arr=(a b c)
- Indexed assignment: arr[0]=value
- Element access: ${arr[0]}
- All elements: ${arr[@]} ${arr[*]}
- Array length: ${#arr[@]}
AST changes:
- Assignment now has optional index for arr[n]=value
- AssignmentValue enum: Scalar vs Array
- WordPart::ArrayAccess for ${arr[index]}
- WordPart::ArrayLength for ${#arr[@]}
Parser changes:
- Handle arr=(...) syntax with separate tokens
- Parse array subscripts in assignments
- Parse ${arr[...]} access patterns
- Don't treat arr=( as function definition
Interpreter changes:
- HashMap<String, HashMap<usize, String>> for array storage
- Expand array access with @/* for all elements
- Evaluate arithmetic in array indices
Tests: 104 passing (+4 array tests)
https://claude.ai/code/session_01A16cD8ztbTJs2PB2iHe1Ua
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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
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.
Summary
Add indexed array support to the bash interpreter.
Features
Array Declaration
arr=(a b c)- Array literal assignmentarr[0]=value- Indexed element assignmentArray Access
${arr[0]}- Single element access${arr[@]}and${arr[*]}- All elements${#arr[@]}- Array length (number of elements)Implementation
AST Changes
Assignmentnow has optionalindexfield forarr[n]=valueAssignmentValueenum:Scalar(Word)vsArray(Vec<Word>)WordPart::ArrayAccess { name, index }for${arr[...]}WordPart::ArrayLength(name)for${#arr[@]}Parser Changes
arr=(...)syntax where(is a separate token${arr[...]}access patterns in wordsarr=(as function definitionInterpreter Changes
arrays: HashMap<String, HashMap<usize, String>>storage@or*to all elementsTest plan