From: "Petteri Räty" <betelgeuse@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/, bashast/gunit/
Date: Thu, 4 Aug 2011 13:53:42 +0000 (UTC) [thread overview]
Message-ID: <b162a7bd8490e4224ce42c417ae12ba120d681ad.betelgeuse@gentoo> (raw)
commit: b162a7bd8490e4224ce42c417ae12ba120d681ad
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Jul 22 12:32:50 2011 +0000
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Aug 2 07:52:18 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=b162a7bd
Parser&Walker: support nested arithmetic expansion
---
bashast/bashast.g | 3 ++-
bashast/gunit/arith_main.gunit | 1 +
bashast/libbashWalker.g | 1 +
scripts/binary_arithmetic.bash | 1 +
4 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/bashast/bashast.g b/bashast/bashast.g
index dd14f24..9c34478 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -874,7 +874,7 @@ commasep
: brace_expansion_part (COMMA! brace_expansion_part)+;
explicit_arithmetic
- : arithmetic_part
+ : (DOLLAR (LLPAREN|LSQUARE)) => arithmetic_part // (the predicate resolves the conflict with the primary rule)
| arithmetics;
arithmetic_expansion
@@ -921,6 +921,7 @@ primary
| command_substitution
| variable_name_no_digit -> ^(VAR_REF variable_name_no_digit)
| variable_reference
+ | arithmetic_expansion
| LPAREN! (arithmetics) RPAREN!;
pre_post_primary
: primary;
diff --git a/bashast/gunit/arith_main.gunit b/bashast/gunit/arith_main.gunit
index 7620fd7..7e04dc3 100644
--- a/bashast/gunit/arith_main.gunit
+++ b/bashast/gunit/arith_main.gunit
@@ -130,6 +130,7 @@ arithmetics_test:
arithmetic_expansion:
"$((5+4, 3+2, a*b))" -> (ARITHMETIC_EXPRESSION (+ 5 4) (+ 3 2) (* (VAR_REF a) (VAR_REF b)))
"$[1]" -> (ARITHMETIC_EXPRESSION 1)
+"$(($((1))))" -> (ARITHMETIC_EXPRESSION (ARITHMETIC_EXPRESSION 1))
start:
"echo $(( 3 + 2 ))" -> (LIST (COMMAND (STRING echo) (STRING (ARITHMETIC_EXPRESSION (+ 3 2)))))
diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index f4ebaaf..d1bbe93 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -1201,5 +1201,6 @@ arithmetics returns[long value]
}
| NUMBER { $value = parse_integer($NUMBER);}
| DIGIT { $value = parse_integer($DIGIT);}
+ |^(ARITHMETIC_EXPRESSION l=arithmetics) { $value = l; }
| ^(VAR_REF libbash_string = var_expansion) { $value = boost::lexical_cast<long>(libbash_string); }
;
diff --git a/scripts/binary_arithmetic.bash b/scripts/binary_arithmetic.bash
index cac471f..c5f018c 100644
--- a/scripts/binary_arithmetic.bash
+++ b/scripts/binary_arithmetic.bash
@@ -69,3 +69,4 @@ echo "$((FOO059||FOO059++))"
echo "$((0&&FOO059++))"
echo "$(( 1 == 2))"
echo "$(( 1 == 1))"
+echo $(($((1))))
next reply other threads:[~2011-08-04 13:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-04 13:53 Petteri Räty [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-06-03 9:08 [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/, bashast/gunit/ Petteri Räty
2012-06-03 9:08 Petteri Räty
2012-06-03 9:08 Petteri Räty
2012-06-03 9:08 Petteri Räty
2012-06-03 9:08 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-06-09 8:15 Petteri Räty
2011-06-09 7:27 Petteri Räty
2011-05-22 21:00 Petteri Räty
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b162a7bd8490e4224ce42c417ae12ba120d681ad.betelgeuse@gentoo \
--to=betelgeuse@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox