EgonOlsen71 / basicv2

A Commodore (CBM) BASIC V2 interpreter/compiler written in Java
https://egonolsen71.github.io/basicv2/
The Unlicense
84 stars 15 forks source link

parser doesn't detect this error #19

Closed nippur72 closed 5 years ago

nippur72 commented 5 years ago

While trying compile some .bas of mine, I discovered the parser doesn't detect the errors in 160 and 170 below:

160 a=peek(56320) rem // legge joystick in porta 2
170 a=peek(56320) // legge joystick in porta 2
180 print a

P.S. this is truly an amazing project, I'm impressed.

EgonOlsen71 commented 5 years ago

Thanks for the report. These were actually three problems in one...

1.) The function parser was happy with itself once he managed to extract a function call and ignored the rest if it doesn't contain any more operations. I've fixed this. 2.) // (or two multiplications) was somehow treated as two operators in a row, which were ignored later in the process...I've fixed this, but it lead to... 3.) ...another problem showing up in the expression parser when it tried to parse things like 2-3^2. In that case, it simply ignored the 2, which I didn't catch earlier, because my test case was 1*-...:-). This should be fixed now as well.