skx / gobasic

A BASIC interpreter written in golang.

Home Page:https://blog.steve.fi/tags/basic/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Suppose for NEXT without variable

udhos opened this issue · comments

commented

gobasic should support NEXT without a variable.

The NEXT variable should be optional unless for BASIC code collapsing multiple FOR loops into the same NEXT (10 for a=1 to 2: for b=3 to 5: next b,a).

Documentation: https://hwiegman.home.xs4all.nl/gw-man/FORNEXT.html

$ gobasic next.bas 
1Error running program:
	Line 30 : Expected IDENT after NEXT in FOR loop, got Token{Type:NEWLINE Value:\n}
$ 
$ more next.bas 
10 for i=1 to 3
20 print i
30 next

Some BASICs allow this. e.g. visual-basic:

Some BASIC implementations do not.

  • e.g. ZX Spectrum

When I've been in doubt, I've gone with the latter approach.