abs icon indicating copy to clipboard operation
abs copied to clipboard

FOR loop does not accept compound addition in increment section

Open mlongval opened this issue 2 years ago • 0 comments

I think I have found a little bug in the increment section of the FOR loop. This code works fine:

#!/usr/bin/env abs
# the first 100 terms of the fibonnaci sequence

t1 = 0      # first term
t2 = 1      # second term

max = 100   # max number of iterations

echo(t1)
echo(t2)

for counter = 0; counter < max; counter = counter + 1 {
    t3 = t1 + t2
    echo(t3)
    t1 = t2
    t2 = t3
}

But this version:

#!/usr/bin/env abs
# the first 100 terms of the fibonnaci sequence

t1 = 0      # first term
t2 = 1      # second term

max = 100   # max number of iterations

echo(t1)
echo(t2)

for counter = 0; counter < max; counter += 1 {
    t3 = t1 + t2
    echo(t3)
    t1 = t2
    t2 = t3
}

Gives me this error:

parser errors:
        expected next token to be IDENT, got = instead
        [13:5]      t3 = t1 + t2
        no prefix parse function for '=' found
        [13:8]      t3 = t1 + t2
        no prefix parse function for '}' found
        [17:1]  }

Otherwise this is a nice little scripting language. Thanks

mlongval avatar May 15 '23 06:05 mlongval