Gentoo Archives: gentoo-commits

From: "Petteri Räty" <betelgeuse@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/libbash:master commit in: bashast/, test/, bashast/gunit/
Date: Wed, 01 Jun 2011 12:03:35
Message-Id: 5f561a36bfefb24ad61f2848536317e62328301c.betelgeuse@gentoo
1 commit: 5f561a36bfefb24ad61f2848536317e62328301c
2 Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
3 AuthorDate: Mon May 30 08:42:14 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Wed Jun 1 06:12:20 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=5f561a36
7
8 Parser: support nested function definitions
9
10 ---
11 bashast/bashast.g | 3 ++-
12 bashast/gunit/function.gunit | 2 ++
13 test/verify_error_output_test.sh | 2 +-
14 3 files changed, 5 insertions(+), 2 deletions(-)
15
16 diff --git a/bashast/bashast.g b/bashast/bashast.g
17 index c560644..88a44cf 100644
18 --- a/bashast/bashast.g
19 +++ b/bashast/bashast.g
20 @@ -111,7 +111,7 @@ flcomment
21 clist
22 : list_level_2 -> ^(LIST list_level_2);
23 list_level_1
24 - : (function|pipeline) (BLANK!*(LOGICAND^|LOGICOR^)BLANK!* (function|pipeline))*;
25 + : pipeline (BLANK!*(LOGICAND^|LOGICOR^)BLANK!* pipeline)*;
26 // ';' '&' and EOL have lower operator precedence than '&&' and '||' so we need level2 here
27 list_level_2
28 : list_level_1 (BLANK!? command_separator (BLANK!? EOL!)* BLANK!? list_level_1)*;
29 @@ -127,6 +127,7 @@ time_posix
30 //The structure of a command in bash
31 command
32 : compound_command
33 + | function
34 | simple_command;
35 //Simple bash commands
36 simple_command
37
38 diff --git a/bashast/gunit/function.gunit b/bashast/gunit/function.gunit
39 index 6ee6c68..612ff4a 100644
40 --- a/bashast/gunit/function.gunit
41 +++ b/bashast/gunit/function.gunit
42 @@ -40,6 +40,8 @@ function:
43 "function help { echo 3; } 2> /dev/null > output" OK
44 "xorg-2_reconf_source() { :; }" -> (function (STRING xorg - 2 _reconf_source) (CURRENT_SHELL (LIST (COMMAND (STRING :)))))
45
46 +"function out() { function inner() { :; }; }" -> (function (STRING out) (CURRENT_SHELL (LIST (function (STRING inner) (CURRENT_SHELL (LIST (COMMAND (STRING :))))))))
47 +
48 function_name:
49 "xemacs-packages_src_unpack" OK
50 "while" OK
51
52 diff --git a/test/verify_error_output_test.sh b/test/verify_error_output_test.sh
53 index b3c2eed..e50252f 100755
54 --- a/test/verify_error_output_test.sh
55 +++ b/test/verify_error_output_test.sh
56 @@ -2,4 +2,4 @@
57
58 illegal="${srcdir}/scripts/illegal_script.sh"
59 output=$(./variable_printer "$illegal" 2>&1)
60 -[[ $output == "${illegal}(1) : error 5 : Unexpected token, at offset 3"* ]]
61 +[[ $output == "${illegal}(1) : error 3 : 128:1: command : ( compound_command | function | simple_command );, at offset 3"* ]]