mayankmahajan24 / QL

QL Language and Compiler, for Programming Langauges and Translators Course Fall 2015
4 stars 2 forks source link

While/for #34

Closed anshulkgupta closed 8 years ago

anshulkgupta commented 8 years ago

Addition of where/for loop syntax with relevant tests as needed. See files for description. This branch was created off of the ifelse_mayank_gary one.

BUG BELOW HAS BEEN FIXED.

Refer to issue #36 for more info:

I came across a weird bug in our compiler that doesn’t allow for initialisation of new variables inside the scope of a while loop. I spent a little time going through our static semantic checker that passes the env variable around but couldn’t really locate the exact source of the problem. Anybody has any insights into this?

int a = 1

while (a < 5) {
    a = a + 1
    int temp = 1
    while (temp <= a) {
        print(a)
    temp = temp + 1
    }
}

kept on failing whereas the following worked perfectly:

int a = 1
int temp = 1

while (a < 5) {
    a = a + 1
    temp = 1
    while (temp <= a) {
        print(a)
        temp = temp + 1
    }
}
mattpiccolella commented 8 years ago

@anshulkgupta so I believe what's happening is that we don't pass that scope back - we declare the variables and do the semantic checking but we don't declare the variables' type inside the statement - this is bad because we need to be able to declare new json and thus new json selectors inside of our while loops - can you open an issue for this?

mattpiccolella commented 8 years ago

Actually @anshulkgupta I think I have a pretty easy fix - I'll take care of this with my json changes

anshulkgupta commented 8 years ago

also now resolves #36