abs-lang / abs

Home of the ABS programming language: the joy of shell scripting.
https://www.abs-lang.org
MIT License
510 stars 35 forks source link

FOR loop does not accept compound addition in increment section #491

Open mlongval opened 1 year ago

mlongval commented 1 year ago

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