define switch function r-expression
as
    do scan #current-input
        match "+" term r-expression
            ;pop two integers, add them, push the result
        match "-" term r-expression
            ;pop two integers, subtract them, push the result

    done
    ;if not matched above, accept the empty string
    return true

Example 8: Right-recursive arithmetic evaluation.

Back to Article