skx / gobasic

A BASIC interpreter written in golang.
https://blog.steve.fi/tags/basic/
GNU General Public License v2.0
323 stars 27 forks source link

Consider implementing DATA + READ #47

Closed skx closed 5 years ago

skx commented 5 years ago

We could scan the program for DATA-statements at load-time, much like we do for line-numbers. Assume our Interpreter object had:

    dOffset := 0
    data = []int

Every time we see READ we just return the next value, it is (obviously) a fatal error to read too much.

Sample program(s) here:

NOTE: Because READ needs a reference to variables we have to put it in our core. Similarly DATA needs to be in our core.