[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
About ARITH_CMD
From: |
Peng Yu |
Subject: |
About ARITH_CMD |
Date: |
Thu, 14 Feb 2019 16:03:35 -0600 |
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
- About ARITH_CMD,
Peng Yu <=