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/, bashast/gunit/
Date: Thu, 09 Jun 2011 13:41:40
Message-Id: 6d0105614b316397162aa9167fcb2d88bb0782cf.betelgeuse@gentoo
1 commit: 6d0105614b316397162aa9167fcb2d88bb0782cf
2 Author: Petteri Räty <petsku <AT> petteriraty <DOT> eu>
3 AuthorDate: Thu Jun 9 12:42:09 2011 +0000
4 Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
5 CommitDate: Thu Jun 9 12:42:09 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=6d010561
7
8 Parser: trailing white space in command lists
9
10 The redirect rule was stopping trailing white space from parsing
11 properly. With refactoring our grammar handles it properly.
12
13 ---
14 bashast/bashast.g | 17 +++++++++--------
15 bashast/gunit/command_sub.gunit | 1 +
16 2 files changed, 10 insertions(+), 8 deletions(-)
17
18 diff --git a/bashast/bashast.g b/bashast/bashast.g
19 index 9cd8ca1..4b132f5 100644
20 --- a/bashast/bashast.g
21 +++ b/bashast/bashast.g
22 @@ -131,9 +131,9 @@ command
23 | simple_command;
24 //Simple bash commands
25 simple_command
26 - : variable_definitions BLANK!+ bash_command^ redirect*
27 + : variable_definitions BLANK!+ bash_command^ redirect?
28 | variable_definitions -> ^(VARIABLE_DEFINITIONS variable_definitions)
29 - | bash_command^ redirect*;
30 + | bash_command^ redirect?;
31 variable_definitions
32 : var_def (BLANK!+ var_def)*
33 | LOCAL BLANK!+ local_item (BLANK!+ local_item)*
34 @@ -146,10 +146,11 @@ export_item
35 |name ->;
36 bash_command
37 : fname_no_res_word (BLANK+ fname)* -> ^(COMMAND fname_no_res_word fname*);
38 -redirect: BLANK!* here_string_op^ BLANK!* fname
39 - | BLANK!* here_doc_op^ BLANK!* fname EOL! heredoc
40 - | BLANK* redir_op BLANK* redir_dest -> ^(REDIR redir_op redir_dest)
41 - | BLANK!* process_substitution;
42 +redirect: (BLANK!* redirect_atom)*;
43 +redirect_atom: here_string_op^ BLANK!* fname
44 + | here_doc_op^ BLANK!* fname EOL! heredoc
45 + | redir_op BLANK* redir_dest -> ^(REDIR redir_op redir_dest)
46 + | process_substitution;
47 redir_dest
48 : file_desc_as_file //handles file descriptors
49 | fname; //path to a file
50 @@ -229,10 +230,10 @@ case_pattern
51 | fname
52 | TIMES;
53 //A grouping of commands executed in a subshell
54 -subshell: LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAREN redirect* -> ^(SUBSHELL clist redirect*);
55 +subshell: LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAREN redirect? -> ^(SUBSHELL clist redirect?);
56 //A grouping of commands executed in the current shell
57 current_shell
58 - : LBRACE wspace clist semiel wspace* RBRACE redirect* -> ^(CURRENT_SHELL clist redirect*);
59 + : LBRACE wspace clist semiel wspace* RBRACE redirect? -> ^(CURRENT_SHELL clist redirect?);
60 //comparison using arithmetic
61 arith_comparison
62 : LLPAREN wspace? arithmetic wspace? RRPAREN -> ^(COMPOUND_ARITH arithmetic);
63
64 diff --git a/bashast/gunit/command_sub.gunit b/bashast/gunit/command_sub.gunit
65 index 6cf07de..210ad63 100644
66 --- a/bashast/gunit/command_sub.gunit
67 +++ b/bashast/gunit/command_sub.gunit
68 @@ -21,5 +21,6 @@ gunit bashast;
69 command_sub:
70 "$(echo \"foo\")" -> (COMMAND_SUB (LIST (COMMAND (STRING echo) (STRING (DOUBLE_QUOTED_STRING foo)))))
71 "$(ls |grep file)" -> (COMMAND_SUB (LIST (| (COMMAND (STRING ls)) (COMMAND (STRING grep) (STRING file)))))
72 +"$(CONTROL= command arg )" -> (COMMAND_SUB (LIST (COMMAND (STRING command) (STRING arg) (= CONTROL))))
73 "`cat output.log |grep error|cut`" -> (COMMAND_SUB (LIST (| (| (COMMAND (STRING cat) (STRING output . log)) (COMMAND (STRING grep) (STRING error))) (COMMAND (STRING cut)))))
74 "$(function foo() { echo 'hello'; }; foo)" -> (COMMAND_SUB (LIST (function (STRING foo) (CURRENT_SHELL (LIST (COMMAND (STRING echo) (STRING (SINGLE_QUOTED_STRING hello)))))) (COMMAND (STRING foo))))