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 ) id 1QQe2p-0004Xw-0L for garchives@archives.gentoo.org; Sun, 29 May 2011 11:20:31 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 826F81C03B; Sun, 29 May 2011 11:20:07 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 4E4B31C02A for ; Sun, 29 May 2011 11:20:07 +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 E3AAA1B4059 for ; Sun, 29 May 2011 11:20:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 473018001B for ; Sun, 29 May 2011 11:20:06 +0000 (UTC) From: "Petteri Räty" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Petteri Räty" Message-ID: 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 X-VCS-Directories: scripts/ bashast/ X-VCS-Committer: betelgeuse X-VCS-Committer-Name: Petteri Räty X-VCS-Revision: c3356056896f2fab67e11cf4b4165487b6832211 Date: Sun, 29 May 2011 11:20:06 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: a4c7db4609d09a3c4e22eb9b4dc5837f commit: c3356056896f2fab67e11cf4b4165487b6832211 Author: Mu Qiao gentoo org> AuthorDate: Sat May 28 15:59:20 2011 +0000 Commit: Petteri R=C3=A4ty gentoo org> CommitDate: Sun May 29 11:44:52 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/libbash.git;a= =3Dcommit;h=3Dc3356056 Walker: use any_string for function name The name rule doesn't cover all the possible characters in function names. As we've already validated the function name in parser grammar, the any_string rule is sufficient to match the function name. --- bashast/libbashWalker.g | 8 ++++++-- scripts/function_def.bash | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g index 5c8c371..e61d7b6 100644 --- a/bashast/libbashWalker.g +++ b/bashast/libbashWalker.g @@ -826,9 +826,13 @@ command_substitution returns[std::string libbash_val= ue] }; =20 function_definition returns[int placeholder] - :^(FUNCTION ^(STRING name) { +@declarations { + std::string function_name; +} + // We've already validated the function name in parser grammar so here = we just use any_string to match the name. + :^(FUNCTION ^(STRING (libbash_string=3Dany_string { function_name +=3D = libbash_string; })+) { // Define the function with current index - walker->define_function($name.libbash_value, INDEX()); + walker->define_function(function_name, INDEX()); // Skip the AST for function body seek_to_next_tree(ctx); }); diff --git a/scripts/function_def.bash b/scripts/function_def.bash index 54030e7..53e5ec8 100644 --- a/scripts/function_def.bash +++ b/scripts/function_def.bash @@ -27,20 +27,20 @@ ARRAY=3D(1 2 3) func_with_args ${ARRAY[@]} $FOO001 func_with_args 100 $ARG2 $ARG3 $ARG4 =20 -func_with_return() +func-with-return() { return 1 NOT_EXIST=3D1 } -func_with_return +func-with-return RETURN_STATUS=3D$? -func_with_return2() +func_with-return2() { true return NOT_EXIST=3D1 } -func_with_return2 +func_with-return2 RETURN_STATUS2=3D$? =20 func_nested1() {