lwgray / think

MIT License
0 stars 1 forks source link

Add Dictionary and Indexing Support Fix #29 #30

Closed lwgray closed 1 week ago

lwgray commented 1 week ago

Description

This PR adds support for dictionaries and indexing operations to ThinkPy, enhancing its ability to teach data structure concepts and bringing it closer to Python's feature set.

Changes Made

  1. Added dictionary literal syntax and AST nodes
  2. Implemented indexing for lists and dictionaries
  3. Added support for nested data structures
  4. Enhanced error handling for invalid operations
  5. Removed legacy tuple-based AST approach
  6. Updated documentation

Example Usage

objective "Demonstrate new features"

task "Dictionary Operations" {
    step "Create and access dictionary" {
        user = {
            "name": "Alice",
            "scores": [85, 92, 78]
        }
        print(user["name"])           # Access dict value
        print(user["scores"][0])      # Nested access
    }
}

Testing Done

Need these Documentation Updates

Breaking Changes

None. All existing ThinkPy code will continue to work as before.

Related Issues

Closes #29

Checklist