Scoping isn't returned for loops
mattpiccolella opened this issue · comments
Matt Piccolella commented
We should be returning a list of symbol tables, one of which goes with each statement - I believe this can be done by just returning env
in check_statements
at each step, then using List.map
in our call - then we just pass that list to semantic_to_jast
, so we have a 1-to-1 mapping with statement and symbol table.
Anshul Gupta commented
will try to get this done by our Tuesday meeting!
Anshul Gupta commented
scoping is actually returned! the problem was that the order of evaluation was wrong:
int a = 1
while (a < 5) {
a = a + 1
int temp = 1
while (temp <= a) {
print(a)
temp = temp + 1
}
}
the body of the outer while loop should be evaluated as
a = a + 1
int temp = 1
while (temp <= a) {
print(a)
temp = temp + 1
}
but was being evaluated as
while (temp <= a) {
print(a)
temp = temp + 1
}
int temp = 1
a = a + 1