It was reported that the following program fails, due to issues with swallowing newlines:
REM This is a comment
PRINT "OK"
This comes about because the swallowLine implementation we have consumes the newline it uses to stop its search, however the interpreter then goes on to increment the line:
func (e *Interpreter) RunOnce() error {
..
case token.REM:
err = e.swallowLine()
case token.RETURN:
...
..
//
// Ready for the next instruction
//
e.offset++
//
// Error?
//
if err != nil {
return err
}
return nil
As an easy fix for the moment I've updated the swallowLine implementation to actually return with the current token being the newline, not the one after that:
The interpreter will already silently NOP an inline newline.
This shouldn't break the IF/THEN/ELSE code.
A similar solution would have been to add a break after the token.REM handler, but special-casing that felt wrong.
It was reported that the following program fails, due to issues with swallowing newlines:
This comes about because the
swallowLine
implementation we have consumes the newline it uses to stop its search, however the interpreter then goes on to increment the line:As an easy fix for the moment I've updated the swallowLine implementation to actually return with the current token being the newline, not the one after that:
A similar solution would have been to add a break after the token.REM handler, but special-casing that felt wrong.
This closes #122.