Having line numbers is pretty much essential for BASIC. This, and its half-brother FORTRAN were, after all, the inspiration for Djikstra’s “Goto considered harmful” – GOTO and the (later addition) GOSUBwere what we used before we had procedures and functions, never mind classes and methods.
But Java (and hence Groovy) has no support for goto statements (it is a reserved word in the language though – but presumably to stop someone actually implementing it.) And labelling support, which might offer an alternative, is absolutely minimal and inflexible.
I thought about parsing the BASIC file line by line – code lines could be in an array and a GOTO interpreted as a signal to process the array for a different starting point. But that is not easy – each line is treated as a stand alone script if that way is chosen and so I would have to set up the environment every time (or, maybe, I could get round that with the binding – I will have to explore that).
There is a Scala BASIC DSL that I could study further, but I don’t know any Scala (beyond its apparent C/C++/Java heritage) – but it seems to process the input line by line, certainly it seems to have a line class.
Subroutines ought to be a bit easier – they can be closures I suspect.