totalspectrum / flexprop

Simple GUI for Propeller development (both P1 and P2)
Other
38 stars 15 forks source link

Spin2 comparison operators #65

Closed jrullan closed 1 year ago

jrullan commented 1 year ago

Hi, I found an issue with the comparison operators in spin, at least this case. The version that works correctly is the one with spaces before and after the comparison operator, the other doesn't. Correct result should be the same in both cases: "Within range".

PUB main()|x,y,z
  x := 1
  y := 2
  z := x-y '-1

  'Incorrect result in comparison  
  if z>1 OR z<-1
    debug("Out of range")
    debug(sdec(z))
  else
    debug("Within range")
    debug(sdec(z))

  'Correct result
  if z > 1 OR z < -1
    debug("Out of range")
    debug(sdec(z))
  else
    debug("Within range")
    debug(sdec(z))   
( Entering terminal mode.  Press Ctrl-] or Ctrl-Z to exit. )                    
Cog0  Out of range                                                              
Cog0  z = -1                                                                    
Cog0  Within range                                                              
Cog0  z = -1  
totalspectrum commented 1 year ago

It's a conflict between Spin1 and Spin2. In Spin1 the tokens "<-" mean "rotate left", so "z<-1" is parsed as "z (<-) 1" which means "z ROL 1". In Chip's Spin2 "<-" is no longer recognized, but FlexSpin still supported the old Spin1 operators even in Spin2. I'll change that, but for now it's probably best for you to insert the spaces -- this will also help avoid confusion for people who are used to reading Spin1 but not Spin2.

jrullan commented 1 year ago

Oh... I see. I guess for now I'll do that. I discover this code in a driver I'm using. Already fixed it.

totalspectrum commented 1 year ago

This should be fixed in the final 5.9.22 version.