diff --git a/main.leg b/main.leg index a941e56..c057ad4 100644 --- a/main.leg +++ b/main.leg @@ -1,6 +1,6 @@ # main.leg -- C parser + interpreter # -# Last edited: 2025-01-22 21:08:24 by piumarta on zora +# Last edited: 2025-01-22 23:32:08 by piumarta on zora %{ ; @@ -1922,6 +1922,11 @@ oop eval(oop exp, oop env) oop lhs = get(exp, Assign,lhs); oop rhs = eval(get(exp, Assign,rhs), nil); switch (getType(lhs)) { + case Symbol: { + lhs = Scope_lookup(lhs); + if (Variable != getType(lhs)) break; + return set(lhs, Variable,value, rhs); + } case Dereference: { lhs = eval(get(lhs, Dereference,rhs), nil); switch (getType(lhs)) { diff --git a/test.txt b/test.txt index bf1c7d7..3a94aa7 100755 --- a/test.txt +++ b/test.txt @@ -15,6 +15,8 @@ int main(int argc, char **argv) printf("x is %d p is %p\n", *p, p); *p = 666; printf("x is %d %d\n", x, *p); + x = 123; + printf("x is %d %d\n", x, *p); return 0; }