jsseng / arduino_robot

1 stars 2 forks source link

error with if condition #68

Closed jsseng closed 9 years ago

jsseng commented 9 years ago

Given the following input:

var a = 2
if a = 1  {
    display "test"
}

I get the following error:

Caught Exception: expected '{', found '=' [Line 2]
ooee123 commented 9 years ago

Ahh, here is something.

Right now, equality can be done using any of these keywords

eq | equals | noteq | notequals

The "=" is reserved only for assignments.

True, we can detect if an assignment operator is used inside an if conditional, then warn the user. If we wish, we can take it further and convert that assignment operator into an equality operator. I'm okay with leaving it with the eq, noteq, equals, and notequals keywords since we've cut != and ==, but I will welcome any input. Dr. Keen or Lana?

jsseng commented 9 years ago

The only confusing part for me was supporting the <, >, <=, and >= operators, but then checking for equality requires the word 'equals' or 'notequals'.

aaronkeen commented 9 years ago

We had agreed that '=' is reserved only for assignments and that assignments are statements. As such, there should be an error if '=' is used inside the guard of an if.