richpl / PyBasic

Simple interactive BASIC interpreter written in Python
GNU General Public License v3.0
165 stars 45 forks source link

Add logic to ignore everything on REM statement #28

Closed RetiredWizard closed 3 years ago

RetiredWizard commented 3 years ago

This change will prevent mismatched quotes or unrecognized tokens on a REM statement from generating Syntax Errors

brickbots commented 3 years ago

I've spotted this bug when loading some older programs with punctuation in remarks, so it's great to see someone tackling it.

RetiredWizard commented 3 years ago

I think your ideas will work, I don't think I was confident I knew everything lexer was doing when I made these changes so I added the extra logic (and variables) to ensure that I only modified the behavior of a statement whose first token was REM. Looking at it now, that doesn't look to be necessary. The loop format I used was lifted from the string token section but I agree your loop is clearer. I'll test out your mods next week and if they work out update the pull request. Even small reductions in memory usage are great news for running on the RP2040 :). Thanks!

richpl commented 3 years ago

I'll await an updated PR on this one then

RetiredWizard commented 3 years ago

Okay, this is much cleaner, thanks @brickbots ! By moving the remark consuming loop, I was even able to end the loops/routine through the normal flow without having to add an additional break or return :)

I did test this with my largest two program (adventure and startrek) and all seems to work fine.