From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from <gentoo-commits+bounces-347386-garchives=archives.gentoo.org@lists.gentoo.org>) id 1QOswD-00083k-PL for garchives@archives.gentoo.org; Tue, 24 May 2011 14:50:26 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 977CB1C00F; Tue, 24 May 2011 14:50:13 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 686101C00F for <gentoo-commits@lists.gentoo.org>; Tue, 24 May 2011 14:50:13 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F024D1BC01B for <gentoo-commits@lists.gentoo.org>; Tue, 24 May 2011 14:50:12 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 4C1D18050A for <gentoo-commits@lists.gentoo.org>; Tue, 24 May 2011 14:50:12 +0000 (UTC) From: "Petteri Räty" <betelgeuse@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" <betelgeuse@gentoo.org> Message-ID: <4f707ab4ec05da9c311b28fb4aeb07a345f8ef28.betelgeuse@gentoo> Subject: [gentoo-commits] proj/libbash:master commit in: scripts/, bashast/ X-VCS-Repository: proj/libbash X-VCS-Files: bashast/libbashWalker.g scripts/function_def.bash scripts/function_def.bash.result X-VCS-Directories: scripts/ bashast/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: 4f707ab4ec05da9c311b28fb4aeb07a345f8ef28 Date: Tue, 24 May 2011 14:50:12 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 1b3e54e2fc7b80629485c40418459fa4 commit: 4f707ab4ec05da9c311b28fb4aeb07a345f8ef28 Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org> AuthorDate: Sun May 22 13:48:02 2011 +0000 Commit: Petteri R=C3=A4ty <betelgeuse <AT> gentoo <DOT> org> CommitDate: Mon May 23 15:16:50 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3D4f707ab4 Walker: support function def in compound statement Now we can declare functions inside compound statement. The rule is renamed for better consistency. --- bashast/libbashWalker.g | 5 +++-- scripts/function_def.bash | 12 ++++++++++++ scripts/function_def.bash.result | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index b760f74..0663d1e 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -116,7 +116,7 @@ options =20 start: list|EOF; =20 -list: ^(LIST (function_def|logic_command_list)+); +list: ^(LIST (logic_command_list)+); =20 variable_definitions @declarations { @@ -432,6 +432,7 @@ var_ref [bool double_quoted] returns[std::string libb= ash_value] =20 command :variable_definitions + |function_definition |simple_command |compound_command; =20 @@ -710,7 +711,7 @@ command_substitution returns[std::string libbash_valu= e] walker->trim_trailing_eols($libbash_value); }; =20 -function_def returns[int placeholder] +function_definition returns[int placeholder] :^(FUNCTION ^(STRING name) { // Define the function with current index walker->define_function($name.libbash_value, INDEX()); diff --git a/scripts/function_def.bash b/scripts/function_def.bash index bcf5a4b..101e732 100644 --- a/scripts/function_def.bash +++ b/scripts/function_def.bash @@ -52,3 +52,15 @@ func_nested2() { func_nested1 } func_nested2 + +if true; then + function_in_compound_statement() { + echo "function_in_compound_statement" + } +fi +if false; then + function_in_compound_statement() { + echo "I should not get called" + } +fi +function_in_compound_statement diff --git a/scripts/function_def.bash.result b/scripts/function_def.bash= .result index 2c5783c..a1c9b91 100644 --- a/scripts/function_def.bash.result +++ b/scripts/function_def.bash.result @@ -1,4 +1,5 @@ hi 1 +function_in_compound_statement ARG1=3D100 ARG2=3D2 ARG3=3D3