public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/libbash:master commit in: scripts/, /, bashast/
@ 2011-04-27 15:11 Petteri Räty
  0 siblings, 0 replies; 2+ messages in thread
From: Petteri Räty @ 2011-04-27 15:11 UTC (permalink / raw
  To: gentoo-commits

commit:     f3be58e19e78f86ce1006f2ef33875ba4ec14905
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 25 07:53:35 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 27 14:58:44 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=f3be58e1

Walker: implement test expression

Only a limited set of operation is supported for now: =, ==, !=,
\>, \<.

---
 Makefile.am                   |    2 ++
 bashast/libbashWalker.g       |   18 +++++++++++++++++-
 scripts/test_expr.bash        |   26 ++++++++++++++++++++++++++
 scripts/test_expr.bash.result |    9 +++++++++
 4 files changed, 54 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 0d21393..a21b3ad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -53,6 +53,7 @@ BASH_TESTS = scripts/var_def.bash \
 			 scripts/function_def.bash \
 			 scripts/arithmetic_assignment.bash \
 			 scripts/compound_command.bash \
+			 scripts/test_expr.bash \
 			 scripts/binary_arithmetic.bash
 BASH_RESULT = scripts/var_def.bash.result \
 			  scripts/var_expansion.bash.result \
@@ -60,6 +61,7 @@ BASH_RESULT = scripts/var_def.bash.result \
 			  scripts/function_def.bash.result \
 			  scripts/arithmetic_assignment.bash.result \
 			  scripts/compound_command.bash.result \
+			  scripts/test_expr.bash.result \
 			  scripts/binary_arithmetic.bash.result
 
 TESTS = $(GUNIT_TESTS) $(BASH_TESTS)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 11b4c19..c616c88 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -86,7 +86,6 @@ options
 		SEEK(INDEX() + index - 3);
 		CONSUME();
 	}
-
 }
 
 start: list|EOF;
@@ -321,8 +320,25 @@ command_list: ^(LIST logic_command_list+);
 
 compound_command
 	: ^(CURRENT_SHELL command_list)
+	| ^(COMPOUND_COND cond_expr)
 	| for_expr;
 
+cond_expr
+	:^(BUILTIN_TEST status=builtin_condition) { walker->set_status(!status); };
+
+builtin_condition returns[bool status]
+	:^(NEGATION l=builtin_condition) { $status = !l; }
+	|s=builtin_condition_primary { $status = s; };
+
+builtin_condition_primary returns[bool status]
+	:^(NAME string_expr string_expr) { throw interpreter_exception(walker->get_string($NAME) + "(NAME) is not supported for now");}
+	|^(EQUALS l=string_expr r=string_expr) { $status = (l.libbash_value == r.libbash_value); }
+	|^(NOT_EQUALS l=string_expr r=string_expr) { $status = (l.libbash_value != r.libbash_value); }
+	|^(ESC_LT l=string_expr r=string_expr) { $status = (l.libbash_value < r.libbash_value); }
+	|^(ESC_GT l=string_expr r=string_expr) { $status = (l.libbash_value > r.libbash_value); }
+	|^(LETTER l=string_expr) { throw interpreter_exception(walker->get_string($LETTER) + "(LETTER) is not supported for now");}
+	|string_expr { $status = ($string_expr.libbash_value.size() != 0); };
+
 for_expr
 @declarations {
 	ANTLR3_MARKER commands_index;

diff --git a/scripts/test_expr.bash b/scripts/test_expr.bash
new file mode 100644
index 0000000..95acd36
--- /dev/null
+++ b/scripts/test_expr.bash
@@ -0,0 +1,26 @@
+[ a = b ]
+echo $? # 1
+test a = a
+echo $? # 0
+#[ ]
+#echo $? # 1
+[ abc ]
+echo $? # 0
+[ ! abc ]
+echo $? # 1
+#[ ! ]
+#echo $?
+#[ abc -a bcd ]
+#echo $?
+#[ abc -o bcd ]
+#echo $?
+test abc == abd
+echo $? # 1
+[ abc != bcd ]
+echo $? # 0
+[ abc != abc ]
+echo $? # 1
+[ abc \> bcd ]
+echo $? # 1
+[ abc \< bcd ]
+echo $? # 0

diff --git a/scripts/test_expr.bash.result b/scripts/test_expr.bash.result
new file mode 100644
index 0000000..ff52ae4
--- /dev/null
+++ b/scripts/test_expr.bash.result
@@ -0,0 +1,9 @@
+1
+0
+0
+1
+1
+0
+1
+1
+0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-commits] proj/libbash:master commit in: scripts/, /, bashast/
@ 2011-08-04 13:53 Petteri Räty
  0 siblings, 0 replies; 2+ messages in thread
From: Petteri Räty @ 2011-08-04 13:53 UTC (permalink / raw
  To: gentoo-commits

commit:     3ad149db6ddfb44c6e39777381c9527d2c7e2e0d
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 24 04:10:23 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=3ad149db

Parser: fix here document start

The solution is not ideal but we can not generate metadata without it.
We can improve it in future when we have better approach.

---
 Makefile.am               |    4 ++++
 bashast/bashast.g         |    7 +++++--
 scripts/here_document.ast |    6 +++++-
 scripts/here_document.sh  |   10 ++++++++++
 4 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 97652a8..76f77cb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -87,6 +87,7 @@ TESTS += cppunittests \
 		 test/verify_error_output_test.sh \
 		 test/ast_printer_test.sh \
 		 test/verify_bashs_test.sh \
+		 test/verify_here_document.sh \
 		 test/bash_result_tests.sh
 check_PROGRAMS = cppunittests
 
@@ -278,9 +279,12 @@ EXTRA_DIST = bashast/bashast.g \
 			 test/ast_printer_test.sh \
 			 test/verify_bashs_test.sh \
 			 test/verify_error_output_test.sh \
+			 test/verify_here_document.sh \
 			 test/bash_result_tests.sh \
 			 scripts/naughty_tests \
 			 scripts/naughty_tests.result \
+			 scripts/here_document.ast \
+			 scripts/here_document.sh \
 			 scripts/source_false.sh \
 			 scripts/source_true.sh \
 			 scripts/source_return.sh \

diff --git a/bashast/bashast.g b/bashast/bashast.g
index c987375..9c248e4 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -309,8 +309,11 @@ here_document_begin
 	:	(
 			token=~(EOL|BLANK|LESS_THAN|HERE_STRING_OP|AMP|GREATER_THAN|RSHIFT)
 			{
-				$here_document::here_document_word += get_string($token);
-				$here_document::number_of_tokens++;
+				if(LA(-1) != DQUOTE && LA(-1) != ESC)
+				{
+					$here_document::here_document_word += get_string($token);
+					$here_document::number_of_tokens++;
+				}
 			}
 		)+;
 here_document_end

diff --git a/scripts/here_document.ast b/scripts/here_document.ast
index ca0781c..4dadb03 100644
--- a/scripts/here_document.ast
+++ b/scripts/here_document.ast
@@ -1,3 +1,7 @@
 (LIST (COMMAND (STRING cat) (<< (STRING blah 
  blah 
-) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING hi)))
+) (REDIR > (STRING / dev / null)))) (COMMAND (STRING echo) (STRING hi)) (COMMAND (STRING cat) (REDIR > (STRING (DOUBLE_QUOTED_STRING / dev / null))) (<<- (STRING 
+      java   - Dtijmp . jar = " $(java-config -p tijmp) "   - agentlib : tijmp   " $ { @ } " 
+))) (COMMAND (STRING cat) (REDIR > (STRING (DOUBLE_QUOTED_STRING / dev / null))) (<<- (STRING 
+      java   - Dtijmp . jar = " $(java-config -p tijmp) "   - agentlib : tijmp   " $ { @ } " 
+))))

diff --git a/scripts/here_document.sh b/scripts/here_document.sh
index 2cc15d4..371b2df 100644
--- a/scripts/here_document.sh
+++ b/scripts/here_document.sh
@@ -3,3 +3,13 @@ blah
 blah
 _EOF_.abc
 echo hi
+
+cat > "/dev/null" <<-"EOF"
+    #!/bin/sh
+    java -Dtijmp.jar="$(java-config -p tijmp)" -agentlib:tijmp "${@}"
+EOF
+
+cat > "/dev/null" <<-\EOF
+    #!/bin/sh
+    java -Dtijmp.jar="$(java-config -p tijmp)" -agentlib:tijmp "${@}"
+EOF



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-08-04 13:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-27 15:11 [gentoo-commits] proj/libbash:master commit in: scripts/, /, bashast/ Petteri Räty
  -- strict thread matches above, loose matches on Subject: below --
2011-08-04 13:53 Petteri Räty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox