dmsc / fastbasic

FastBasic - Fast BASIC interpreter for the Atari 8-bit computers
GNU General Public License v2.0
139 stars 20 forks source link

partial reserved word matching in variables #72

Closed marianodominguez closed 7 months ago

marianodominguez commented 1 year ago

Hello. I'm facing errors with certain var names. e.g

u%=0.12
cosu%=cos(u%)
cos4u%=cosu%*cosu%*cosu%*cosu%
u%=90*cos4u%

cannot compile:

BAS compile 'testfloat.bas' to 'testfloat.asm'
testfloat.bas:4:10: parse error, expected: '+', '-'
u%=90*cos4<--- HERE -->u%

all is ok if I rename the variable to c4u%

EricCarrGH commented 1 year ago

This is expected, as function with a single parameter can be called without parentheses.

So, cos(4) is the same as cos 4 or cos4 since space is optional. So, it interprets cos4u as cos(4) and doesn't know what to do with u.

Therefore, I recommend you avoid using any variable names that are the name of real function, or the name of a function followed by a number.

dmsc commented 7 months ago

Closed as not-a-bug. Have Fun!