Hi,

yylex() still gives the token ARITH_CMD for the following command. The
error seems to be raised at the parsing stage. Shouldn't the error be
caught in the lexical analysis stage?

$ ((x = 10 + 5; ++x; echo $x))
bash: ((: x = 10 + 5; ++x: syntax error: invalid arithmetic operator
(error token is "; ++x")

Why the parsing of the arithmetic expression is in the lexical
analysis. Why not introduce token `((` and `))` and handle arithmetic
expression in the bison parsing code?

Also, I don't find that POSIX specifies `((`. (Let me know if I miss
anything.) If `((` is a bash-specific thing, why not allow it to
handle multiple arithmetic expressions instead of just one? Thanks.

http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html

-- 
Regards,
Peng

Reply via email to