skx / gobasic

A BASIC interpreter written in golang.
https://blog.steve.fi/tags/basic/
GNU General Public License v2.0
323 stars 27 forks source link

Conditionals Seem Limited #42

Closed krschwab closed 5 years ago

krschwab commented 5 years ago

This works as expected: IF 1=1 THEN PRINT "TEST" This, however, fails

 IF 1+1 THEN PRINT "TEST"
 Error running program:
       Line  : factor() - unhandled token: Token{Type:PRINT Value:PRINT}

It seems to work fine in other basic interpreters I tried.

skx commented 5 years ago

Currently the format is:

IF [CMP] THEN [STATEMENT]  (ELSE [STATEMENT])

The CMP operator can be:

Your program is trying to do a boolean test, that could be added, but isn't expected to work right now.

skx commented 5 years ago

(The error you get is not great, it tried to parse the expression, jumping foward, and it went too far.)

krschwab commented 5 years ago

Got it. I suppose I can just convert to "IF (WHATEVER)>0" so it's not a barrier.