On Sun, Jul 17, 2016 at 03:20:58PM +0100, Mark Cave-Ayland wrote:
When an evaluate string is split across a newline, the current string position is assumed to be the top-most item on the stack. However in the case of yaboot, items are left on the stack to be used by a subsequent line within the same evaluate statement and so subsequent lines are parsed incorrectly.
Nice catch! These things are hard to debug.
--- a/forth/bootstrap/interpreter.fs +++ b/forth/bootstrap/interpreter.fs @@ -165,7 +165,9 @@ defer outer-interpreter over + over do i c@ 0a = if i over -
rot >r (evaluate)
then loopr> i 1+
This becomes hard to read. So you have (inside the "if"):
( a b ) i over - ( a b i-b ) rot >r ( b i-b R: a ) (evaluate) ( R: a ) r> ( a )
swap >r dup i swap - (evaluate) r>
but that is even longer. Wow. Long definitions are bad, mkay? ;-)
It might be better without the DO loop (it blocks the R stack). Probably it is best to break out a natural factor (like, find the length of a string until the first line break -- isn't there a word like it already, like "left-split" but splitting on any line break char instead of on one delim).
Segher