Add index assignment and augmented assignment

This allows for syntax like `foo['a'] = 1` and more complex assignments
like `foo.bar()[a() + b()] += 1`

Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
2024-10-18 22:03:10 -07:00
parent 43891bd2a3
commit 283eaa1ebe
9 changed files with 221 additions and 45 deletions

View File

@@ -6,3 +6,15 @@ println("to_str")
println(a)
println(['a': 1])
println(['b': 2 + 2])
println("__index_assign__")
a['a'] = 1
println(a)
a['a'] += 1
println(a)
foo = () { return 'a' }
bar = () { return '' }
a[foo() + bar()] += 1
println(a)

View File

@@ -2,3 +2,8 @@ to_str
[:]
['a': 1]
['b': 4]
__index_assign__
['a': 1]
['a': 2]
['a': 3]