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

commit:     e1eb514901068fe62bf51b3cdbb14dc4bace747a
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 15 02:13:40 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun Mar 20 03:22:57 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=e1eb5149

Rename token TEST to avoid conflict

TEST conflicts with gtest (redefine TEST).

---
 bashast/bashast.g |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 06f5320..98638bf 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -275,7 +275,7 @@ arr_var_ref
 cond_expr
 	:	LSQUARE LSQUARE wspace keyword_cond wspace RSQUARE RSQUARE -> ^(KEYWORD_TEST keyword_cond)
 	|	LSQUARE wspace builtin_cond wspace RSQUARE -> ^(BUILTIN_TEST builtin_cond)
-	|	TEST wspace builtin_cond-> ^(BUILTIN_TEST builtin_cond);
+	|	TEST_EXPR wspace builtin_cond-> ^(BUILTIN_TEST builtin_cond);
 cond_primary
 	:	LPAREN! BLANK!* keyword_cond BLANK!* RPAREN!
 	|	keyword_cond_binary
@@ -361,7 +361,7 @@ ns_str_part
 //Parts of strings, no slashes, no reserved words
 ns_str_part_no_res
 	:	num
-	|	name|OTHER|EQUALS|PCT|PCTPCT|MINUS|DOT|DOTDOT|COLON|BOP|UOP|TEST|'_'|TILDE|INC|DEC|ARITH_ASSIGN|ESC_CHAR|CARET;
+	|	name|OTHER|EQUALS|PCT|PCTPCT|MINUS|DOT|DOTDOT|COLON|BOP|UOP|TEST_EXPR|'_'|TILDE|INC|DEC|ARITH_ASSIGN|ESC_CHAR|CARET;
 //strings with no slashes, used in certain variable expansions
 ns_str	:	ns_str_part* -> ^(STRING ns_str_part*);
 //Allowable parts of double quoted strings
@@ -592,7 +592,7 @@ WORDOP	:	(':-'|':='|':?'|':+');
 COLON	:	':';
 QMARK	:	'?';
 //Operators for conditional statements
-TEST	:	'test';
+TEST_EXPR	:	'test';
 LOGICAND
 	:	'&&';
 LOGICOR	:	'||';



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-02 15:50 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-02 15:50 UTC (permalink / raw
  To: gentoo-commits

commit:     41544256fe685b1e58fce9d75beb068ca162c324
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Sat Apr  2 00:50:49 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  2 00:50:49 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=41544256

Support a list of variable definitions

---
 bashast/libbashWalker.g |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index c8e690e..ebb23fe 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -41,6 +41,8 @@ void set_interpreter(std::shared_ptr<interpreter> w)
 }
 }
 
+list: ^(LIST var_def+);
+
 name	returns[std::string libbash_value]:
 	NAME {$libbash_value = walker->get_string($NAME);}
 	|	LETTER {$libbash_value = walker->get_string($LETTER);}



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-02 15:50 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-02 15:50 UTC (permalink / raw
  To: gentoo-commits

commit:     73e07bf1dd111519ddecd79c19c77d64851458e9
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Sat Apr  2 00:52:13 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  2 00:52:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=73e07bf1

Add a start rule for the tree walker grammar

---
 bashast/libbashWalker.g |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index ebb23fe..95c2ff3 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -41,6 +41,8 @@ void set_interpreter(std::shared_ptr<interpreter> w)
 }
 }
 
+start: list|EOF;
+
 list: ^(LIST var_def+);
 
 name	returns[std::string libbash_value]:



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

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

commit:     92991956bc72f52f0a6cfcadef8019c446f45892
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Mon Apr  4 08:50:32 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Apr  4 15:09:11 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=92991956

Split parameter expansion rule

It's easier for the walker to handle if we split the parameter
expansion rule into independent rules.

---
 bashast/bashast.g |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index d83b616..2659ef5 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -253,7 +253,7 @@ var_ref
 	|	DOLLAR BANG -> ^(VAR_REF BANG)
 	|	DOLLAR '_' -> ^(VAR_REF '_');
 //Variable expansions
-var_exp	:	var_name WORDOP^ word
+var_exp	:	var_name (USE_DEFAULT|USE_ALTERNATE|DISPLAY_ERROR|ASSIGN_DEFAULT)^ word
 	|	var_name COLON os=num (COLON len=num)? -> ^(OFFSET var_name $os ^($len)?)
 	|	BANG^ var_name (TIMES|AT)
 	|	BANG var_name LSQUARE (op=TIMES|op=AT) RSQUARE -> ^(LIST_EXPAND var_name $op)
@@ -600,7 +600,10 @@ POUNDPOUND
 PCT	:	'%';
 PCTPCT	:	'%%';
 SLASH	:	'/';
-WORDOP	:	(':-'|':='|':?'|':+');
+USE_DEFAULT	:	':-';
+ASSIGN_DEFAULT:	':=';
+DISPLAY_ERROR:	':?';
+USE_ALTERNATE:	':+';
 COLON	:	':';
 QMARK	:	'?';
 //Operators for conditional statements



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-06 15:07 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-06 15:07 UTC (permalink / raw
  To: gentoo-commits

commit:     9729f542d09b1a370ecd4039a1ae2f77a1d85453
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Wed Apr  6 14:56:30 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr  6 14:56:30 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=9729f542

Simplify var_expansion with syntactic predicates

---
 bashast/libbashWalker.g |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 71aba2e..52d0109 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -86,10 +86,7 @@ var_name returns[std::string libbash_value]
 }:
 	num|name|TIMES|AT;
 
-var_expansion returns[std::string libbash_value]
-@declarations {
-	bool use_length;
-}:
+var_expansion returns[std::string libbash_value]:
 	^(USE_DEFAULT var_name libbash_word=word) {
 		libbash_value = walker->do_default_expansion($var_name.libbash_value, libbash_word);
 	}
@@ -99,11 +96,11 @@ var_expansion returns[std::string libbash_value]
 	|^(USE_ALTERNATE var_name libbash_word=word) {
 		libbash_value = walker->do_alternate_expansion($var_name.libbash_value, libbash_word);
 	}
-	|^(OFFSET var_name offset=arithmetics { use_length = false; } (length=arithmetics { use_length = true; })?) {
-		if(use_length)
-			libbash_value = walker->do_substring_expansion($var_name.libbash_value, offset, length);
-		else
-			libbash_value = walker->do_substring_expansion($var_name.libbash_value, offset);
+	|(^(OFFSET var_name arithmetics arithmetics)) => ^(OFFSET var_name offset=arithmetics length=arithmetics) {
+		libbash_value = walker->do_substring_expansion($var_name.libbash_value, offset, length);
+	}
+	|^(OFFSET var_name offset=arithmetics) {
+		libbash_value = walker->do_substring_expansion($var_name.libbash_value, offset);
 	}
 	|^(POUND var_name) {
 		libbash_value = boost::lexical_cast<std::string>(walker->get_length($var_name.libbash_value));



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-07  7:48 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-07  7:48 UTC (permalink / raw
  To: gentoo-commits

commit:     9224a1e6a4719813c67adaaa995716aedf319b64
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Thu Apr  7 07:05:51 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Apr  7 07:21:47 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=9224a1e6

Simplify first line comment handling

Instead of listing all possible tokens just use negation to find the end
of the comment.

---
 bashast/bashast.g |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 01cc0df..7126bdd 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -81,12 +81,10 @@ tokens{
 	MINUS_SIGN;
 }
 
-start	:	(flcomment! EOL!)? EOL!* list^ ;
+start	:	(flcomment!)? EOL!* list^ ;
 //Because the comment token doesn't handle the first comment in a file if it's on the first line, have a parser rule for it
 flcomment
-	:	BLANK? '#' commentpart*;
-commentpart
-	:	nqstr|BLANK|LBRACE|RBRACE|SEMIC|DOUBLE_SEMIC|TICK|LPAREN|RPAREN|LLPAREN|RRPAREN|PIPE|COMMA|SQUOTE|QUOTE|LESS_THAN|GREATER_THAN;
+	:	'#' ~(EOL)* EOL;
 list	:	list_level_2 BLANK* (';'|'&'|EOL)? -> ^(LIST list_level_2);
 clist
 options{greedy=false;}



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-07 16:44 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-07 16:44 UTC (permalink / raw
  To: gentoo-commits

commit:     b5c3aeace9f791de74b93c35c2118cc67f8db0f1
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Thu Apr  7 09:10:11 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Apr  7 16:39:17 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=b5c3aeac

Use negation to simplify sqstr rule

Instead of listing all the alternatives use negation to find out where
the single quoted string ends.

---
 bashast/bashast.g |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 7126bdd..3d52c27 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -372,10 +372,6 @@ ns_str	:	ns_str_part* -> ^(STRING ns_str_part*);
 dq_str_part
 	:	BLANK|EOL|AMP|LOGICAND|LOGICOR|LESS_THAN|GREATER_THAN|PIPE|SQUOTE|SEMIC|COMMA|LPAREN|RPAREN|LLPAREN|RRPAREN|DOUBLE_SEMIC|LBRACE|RBRACE|TICK|LEQ|GEQ
 	|	str_part_with_pound;
-//Allowable parts of single quoted strings
-sq_str_part
-	:	str_part_with_pound
-	|	BLANK|EOL|AMP|LOGICAND|LOGICOR|LESS_THAN|GREATER_THAN|PIPE|QUOTE|SEMIC|COMMA|LPAREN|RPAREN|LLPAREN|RRPAREN|DOUBLE_SEMIC|LBRACE|RBRACE|DOLLAR|TICK|BOP|UOP;
 //Generic strings/filenames.
 fname	:	nqstr -> ^(STRING nqstr);
 //A string that is NOT a bash reserved word
@@ -411,7 +407,9 @@ dqstr_part
 	|	pattern_match_trigger
 	|	BANG;
 //single quoted string rule, no expansions
-sqstr	:	SQUOTE sq_str_part* SQUOTE -> ^(SINGLE_QUOTED_STRING sq_str_part*);
+sqstr_part
+	: ~SQUOTE*;
+sqstr	:	SQUOTE sqstr_part SQUOTE -> ^(SINGLE_QUOTED_STRING sqstr_part);
 //certain tokens that trigger pattern matching
 pattern_match_trigger
 	:	LSQUARE



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

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

commit:     694e519885ecabfe07970e26a73789635b2c5178
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Fri Apr  8 13:08:39 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Apr  8 13:08:39 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=694e5198

Small fixes for grammar warnings

res_word_str could be removed as an alternative because fname already
includes it and the redirect branch was folded to the common child.

---
 bashast/bashast.g |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 82d1da2..551ae4e 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -114,16 +114,15 @@ arg
 	:	brace_expansion
 	|	var_ref
 	|	fname
-	|	res_word_str -> ^(STRING res_word_str)
 	|	command_sub
 	|	var_ref;
 redirect:	BLANK!* here_string_op^ BLANK!* fname
 	|	BLANK!* here_doc_op^ BLANK!* fname EOL! heredoc
-	|	BLANK* redir_op BLANK* DIGIT MINUS? -> ^(REDIR redir_op DIGIT MINUS?)
 	|	BLANK* redir_op BLANK* redir_dest -> ^(REDIR redir_op redir_dest)
 	|	BLANK!* process_substitution;
 redir_dest
-	:	fname //path to a file
+	:	DIGIT MINUS?
+	|	fname //path to a file
 	|	file_desc_as_file; //handles file descriptors0
 file_desc_as_file
 	:	AMP DIGIT -> FILE_DESCRIPTOR[$DIGIT]



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

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

commit:     b6dbd318c00436d0c4ba5544bcd7fea4e5ce6879
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Fri Apr  8 13:31:40 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Apr  8 13:31:40 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=b6dbd318

Simplify variable definition blank handling

Moved the blank matching from var_def level to simple_command so it only
needs to be specified once.

---
 bashast/bashast.g |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 551ae4e..7f4bed5 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -105,8 +105,7 @@ command
 	|	simple_command;
 //Simple bash commands
 simple_command
-	:	var_def+ bash_command^ redirect*
-	|	bash_command^ redirect*;
+	:	(var_def BLANK!+)* bash_command^ redirect*;
 bash_command
 	:	fname_no_res_word (BLANK+ arg)* -> ^(COMMAND fname_no_res_word arg*);
 //An argument to a command
@@ -217,9 +216,9 @@ cond_comparison
 	:	cond_expr -> ^(COMPOUND_COND cond_expr);
 //Variables
 //Defining a variable
-var_def	:	BLANK* name LSQUARE BLANK? var_index BLANK* RSQUARE EQUALS value BLANK* -> ^(EQUALS ^(name  var_index) value)
-	|	BLANK!* name EQUALS^ value BLANK!*
-	|	BLANK!* LET! name EQUALS^ arithmetic BLANK!*;
+var_def	:	name LSQUARE BLANK? var_index BLANK* RSQUARE EQUALS value -> ^(EQUALS ^(name  var_index) value)
+	|	name EQUALS^ value
+	|	LET! name EQUALS^ arithmetic;
 //Possible values of a variable
 value	:	num
 	|	var_ref



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-09  6:27 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-09  6:27 UTC (permalink / raw
  To: gentoo-commits

commit:     65ce12f8726ace389fb49b479c4a142eeec8eeeb
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Fri Apr  8 14:43:30 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  9 06:13:46 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=65ce12f8

Remove antlr warnings for process_substitution

---
 bashast/bashast.g |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index c20cef4..0580b26 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -485,7 +485,7 @@ arithmetic_condition
 arithmetic_assignment
 	:	(name BLANK!* (EQUALS|MUL_ASSIGN|DIVIDE_ASSIGN|MOD_ASSIGN|PLUS_ASSIGN|MINUS_ASSIGN|LSHIFT_ASSIGN|RSHIFT_ASSIGN|AND_ASSIGN|XOR_ASSIGN|OR_ASSIGN)^ BLANK!*)? logicor;
 process_substitution
-	:	(dir=LESS_THAN|dir=GREATER_THAN)LPAREN BLANK* clist BLANK* RPAREN -> ^(PROCESS_SUBSTITUTION $dir clist);
+	:	(dir=LESS_THAN|dir=GREATER_THAN)LPAREN clist BLANK* RPAREN -> ^(PROCESS_SUBSTITUTION $dir clist);
 //the biggie: functions
 function:	FUNCTION BLANK+ name (BLANK* parens)? wspace compound_command redirect* -> ^(FUNCTION name compound_command redirect*)
 	|	name BLANK* parens wspace compound_command redirect* -> ^(FUNCTION["function"] name compound_command redirect*);



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-09  6:27 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-09  6:27 UTC (permalink / raw
  To: gentoo-commits

commit:     1c08db2941b827b6c768cda6e12b9727ece5168a
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Fri Apr  8 14:21:40 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Fri Apr  8 14:21:40 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=1c08db29

Remove warnings from pipeline time handling

Reorder blank handling so that there's no more warnings.

---
 bashast/bashast.g |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index e167f9f..fde875d 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -95,9 +95,10 @@ list_level_2
 	:	list_level_1 ((BLANK!?';'!|BLANK!?'&'^|(BLANK!? EOL!)+)BLANK!? list_level_1)*;
 pipeline
 	:	var_def+
-	|	time?('!' BLANK!*)? BLANK!* command^ (BLANK!* PIPE^ BLANK!* command)*;
-time	:	TIME^ BLANK!+ timearg?;
-timearg	:	'-p' BLANK!+;
+	|	BLANK!* time? (BANG BLANK!+)? command^ (BLANK!* PIPE^ BLANK!* command)*;
+time	:	TIME^ BLANK!+ time_posix?;
+time_posix
+	:	'-p' BLANK!+;
 //The structure of a command in bash
 command
 	:	EXPORT^ var_def+



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-09  6:27 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-09  6:27 UTC (permalink / raw
  To: gentoo-commits

commit:     3804bbb3116fbf4b81bf86e8c94f1cec7896610d
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Fri Apr  8 15:11:36 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  9 06:13:52 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=3804bbb3

Small readability fixes

---
 bashast/bashast.g |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 0580b26..2b4e713 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -228,7 +228,7 @@ value	:	num
 //allow the parser to create array variables
 arr_val	:
 	|	(ag+=val wspace?)+ -> ^(ARRAY $ag+);
-val	:	'['!BLANK!*var_index BLANK!?']'!EQUALS^ pos_val
+val	:	LSQUARE! BLANK!* var_index BLANK!? RSQUARE! EQUALS^ pos_val
 	|	pos_val;
 pos_val	: command_sub
 	|	var_ref
@@ -467,7 +467,7 @@ negation
 exponential
 	:	negation (BLANK!* EXP^ BLANK!* negation)* ;
 times_division_modulus
-	:	exponential (BLANK!*(TIMES^|SLASH^|PCT^)BLANK!* exponential)*;
+	:	exponential (BLANK!* (TIMES^|SLASH^|PCT^) BLANK!* exponential)*;
 addsub	:	times_division_modulus (BLANK!* (PLUS^|MINUS^)BLANK!* times_division_modulus)*;
 shifts	:	addsub (BLANK!* (LSHIFT^|RSHIFT^) BLANK!* addsub)*;
 compare	:	shifts (BLANK!* (LEQ^|GEQ^|LESS_THAN^|GREATER_THAN^)BLANK!* shifts)?;



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-09  6:27 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-09  6:27 UTC (permalink / raw
  To: gentoo-commits

commit:     149d235bfa4aff7fdbdca9b8a5f1b3fc5b493f34
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Fri Apr  8 19:07:54 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  9 06:13:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=149d235b

Remove backtracking for arg rule

Add syntactic predicates to remove the need to backtrack when evaluation
the arg rule.

---
 bashast/bashast.g |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 5214b65..ec04917 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -109,11 +109,12 @@ simple_command
 bash_command
 	:	fname_no_res_word (BLANK+ arg)* -> ^(COMMAND fname_no_res_word arg*);
 //An argument to a command
+//fname can also match var_ref and command_sub but that gives a noisier AST
 arg
-	:	var_ref
-	|	fname
-	|	command_sub
-	|	var_ref;
+options{backtrack=false;}
+	:	(var_ref) => var_ref
+	|	(command_sub) => command_sub
+	|	fname;
 redirect:	BLANK!* here_string_op^ BLANK!* fname
 	|	BLANK!* here_doc_op^ BLANK!* fname EOL! heredoc
 	|	BLANK* redir_op BLANK* redir_dest -> ^(REDIR redir_op redir_dest)



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-09  6:27 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-09  6:27 UTC (permalink / raw
  To: gentoo-commits

commit:     fa4053e5a365b1ced100736989070b8bd01f33eb
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Fri Apr  8 19:22:57 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  9 06:13:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=fa4053e5

Remove need to backtrack from the word rule

All the other alternatives can also be matched from fname so we need
syntactic predicates. We should give thought to if we need both the word
and fname rules.

---
 bashast/bashast.g |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 64568c9..20068b5 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -330,13 +330,13 @@ wspace	:	BLANK+|EOL;
 semiel	:	(';'|EOL) BLANK*;
 
 //definition of word.  this is just going to grow...
-word	:	brace_expansion
-	|	command_sub
-	|	var_ref
-	|	num
-	|	fname
-	|	arithmetic_expansion
-	|	res_word_str -> ^(STRING res_word_str);
+word	:	(brace_expansion) => brace_expansion
+	|	(command_sub) => command_sub
+	|	(var_ref) => var_ref
+	|	(num) => num
+	|	(arithmetic_expansion) => arithmetic_expansion
+	|	fname;
+
 pattern	:	command_sub
 	|	fname
 	|	TIMES;



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-09  6:36 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-09  6:36 UTC (permalink / raw
  To: gentoo-commits

commit:     19cc04e7c8b61dd7384d850dabcf0e03109fb418
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Apr  9 06:34:49 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  9 06:34:49 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=19cc04e7

Remove useless arithmetic_part rule

---
 bashast/bashast.g |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 20068b5..6230b66 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -439,9 +439,7 @@ extended_pattern_match
 	|	BANG LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_NONE fname+);
 //Arithmetic expansion
 arithmetic_expansion
-	:	DOLLAR LLPAREN BLANK* arithmetic_part BLANK* RRPAREN -> ^(ARITHMETIC_EXPRESSION arithmetic_part);
-arithmetic_part
-	:	arithmetics;
+	:	DOLLAR LLPAREN BLANK* arithmetics BLANK* RRPAREN -> ^(ARITHMETIC_EXPRESSION arithmetics);
 //The comma operator for arithmetic expansions
 arithmetics
 	:	arithmetic (BLANK!* COMMA! BLANK!* arithmetic)*;



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

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

commit:     176fd53977abedfc884aeb064a0775b4fc9c650b
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Apr  8 14:36:33 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  9 13:02:52 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=176fd539

Add comment for list_level_2

---
 bashast/bashast.g |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 7e653df..88f02b8 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -90,6 +90,7 @@ options{greedy=false;}
 	:	list_level_2 -> ^(LIST list_level_2);
 list_level_1
 	:	(function|pipeline) (BLANK!*(LOGICAND^|LOGICOR^)BLANK!* (function|pipeline))*;
+// ';' '&' and EOL have lower operator precedence than '&&' and '||' so we need level2 here
 list_level_2
 	:	list_level_1 ((BLANK!?';'!|BLANK!?'&'^|(BLANK!? EOL!)+)BLANK!? list_level_1)*;
 pipeline



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

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

commit:     2e6b1e607f86161704fa11c3b951770faf2eb327
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Apr  8 14:32:19 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Apr  9 13:02:52 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=2e6b1e60

Change string literals to tokens in parser rules.

String literals in parser rules will create unnecessary tokens
which have already been defined. So we use tokens instead.

---
 bashast/bashast.g |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 356142a..7e653df 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -89,7 +89,7 @@ clist
 options{greedy=false;}
 	:	list_level_2 -> ^(LIST list_level_2);
 list_level_1
-	:	(function|pipeline) (BLANK!*('&&'^|'||'^)BLANK!* (function|pipeline))*;
+	:	(function|pipeline) (BLANK!*(LOGICAND^|LOGICOR^)BLANK!* (function|pipeline))*;
 list_level_2
 	:	list_level_1 ((BLANK!?';'!|BLANK!?'&'^|(BLANK!? EOL!)+)BLANK!? list_level_1)*;
 pipeline



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-11  6:50 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-11  6:50 UTC (permalink / raw
  To: gentoo-commits

commit:     b7d59f3443946171fa6ff74b93bb1f3cd8071e99
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sun Apr 10 12:06:26 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Apr 11 05:23:58 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=b7d59f34

Unreachable alternative removal

Remove underscore alternative from ns_str_part_no_res as it could never
be matched because name before it would always catch it.

---
 bashast/bashast.g |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 31aa368..539cec6 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -366,7 +366,7 @@ ns_str_part_no_res
 	:	num
 	|	name
 	|	esc_char
-	|OTHER|EQUALS|PCT|PCTPCT|MINUS|DOT|DOTDOT|COLON|TEST_EXPR|'_'
+	|OTHER|EQUALS|PCT|PCTPCT|MINUS|DOT|DOTDOT|COLON|TEST_EXPR
 	|TILDE|MUL_ASSIGN|DIVIDE_ASSIGN|MOD_ASSIGN|PLUS_ASSIGN|MINUS_ASSIGN
 	|TIME_POSIX|LSHIFT_ASSIGN|RSHIFT_ASSIGN|AND_ASSIGN|XOR_ASSIGN
 	|OR_ASSIGN|CARET;



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-11  6:50 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-11  6:50 UTC (permalink / raw
  To: gentoo-commits

commit:     69919848b8dad3b2c00bb8be37717270b7eb2240
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sun Apr 10 13:01:40 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Apr 11 06:44:35 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=69919848

Simplify reserved word handling in strings

The paths for strings with reserved words and strings that can't be
reserved code can share most of the code. Now the inclusion of reserved
words is done with the top level rules so we can remove the duplicated
listing.

---
 bashast/bashast.g |   30 ++++++------------------------
 1 files changed, 6 insertions(+), 24 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 539cec6..f44b235 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -357,12 +357,8 @@ str_part_with_pound
 	:	str_part
 	|	POUND
 	|	POUNDPOUND;
-//Parts of strings, no slashes
-ns_str_part
-	:	ns_str_part_no_res
-	|	res_word_str;
 //Parts of strings, no slashes, no reserved words
-ns_str_part_no_res
+ns_str_part
 	:	num
 	|	name
 	|	esc_char
@@ -373,27 +369,13 @@ ns_str_part_no_res
 //strings with no slashes, used in certain variable expansions
 ns_str	:	ns_str_part* -> ^(STRING ns_str_part*);
 //Generic strings/filenames.
-fname	:	nqstr -> ^(STRING nqstr);
+fname	:	fname_part+ -> ^(STRING fname_part+);
 //A string that is NOT a bash reserved word
 fname_no_res_word
-	:	nqstr_no_res_word -> ^(STRING nqstr_no_res_word);
-//No quoted string, no reserved words
-nqstr_no_res_word
-	:	res_word_str (no_res_word_part|str_part_with_pound)+
-	|	no_res_word_part (no_res_word_part|str_part_with_pound)*;
-//parts of strings, not including reserved word parts
-no_res_word_part
-	:	bracket_pattern_match
-	|	extended_pattern_match
-	|	var_ref
-	|	command_sub
-	|	arithmetic_expansion
-	|	brace_expansion
-	|	dqstr
-	|	sqstr
-	|	ns_str_part_no_res
-	|	SLASH
-	|	pattern_match_trigger;
+	:	nqstr fname_part* -> ^(STRING nqstr fname_part*);
+fname_part
+	:	nqstr
+	|	res_word_str;
 //non-quoted string rule, allows expansions
 nqstr	:	(bracket_pattern_match|extended_pattern_match|var_ref|command_sub|arithmetic_expansion|brace_expansion|dqstr|sqstr|(str_part str_part_with_pound*)|pattern_match_trigger|BANG)+;
 //double quoted string rule, allows expansions



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-12  7:19 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-12  7:19 UTC (permalink / raw
  To: gentoo-commits

commit:     339f7d0ec4765a473b45042832ecef1c6bd0e66b
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Mon Apr 11 13:50:16 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Apr 11 13:50:50 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=339f7d0e

Remove special handling for let

let is a builtin like echo so it should not have any special handling in
the parser. Fixes bug #363029.

---
 bashast/bashast.g |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 29e24e2..be93c21 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -213,8 +213,7 @@ cond_comparison
 //Defining a variable
 var_def
 	:	name LSQUARE BLANK? explicit_arithmetic BLANK* RSQUARE EQUALS value -> ^(EQUALS ^(name explicit_arithmetic) value)
-	|	name EQUALS^ value
-	|	LET! name EQUALS^ arithmetic;
+	|	name EQUALS^ value;
 //Possible values of a variable
 value	:	fname
 	|	LPAREN! wspace!? arr_val RPAREN!;
@@ -510,7 +509,6 @@ AT	:	'@';
 DOT	:	'.';
 DOTDOT	:	'..';
 //Arith ops
-LET	:	'let';
 TIMES	:	'*';
 EQUALS	:	'=';
 MINUS	:	'-';



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-12  7:19 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-12  7:19 UTC (permalink / raw
  To: gentoo-commits

commit:     916a065938f083866608344a2967d46dceafcb6b
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Mon Apr 11 15:35:41 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Apr 12 06:23:30 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=916a0659

Simplify the variable expansion rule

Moved things related to replacement matching to helper rules for simpler
code. The parenthesis for offset operators are already handled by the
explicit_arithmetic rule.

---
 bashast/bashast.g |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 9e1d012..2099bf6 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -238,25 +238,25 @@ var_ref
 	|	DOLLAR BANG -> ^(VAR_REF BANG);
 //Variable expansions
 var_exp	:	var_name (USE_DEFAULT|USE_ALTERNATE|DISPLAY_ERROR|ASSIGN_DEFAULT)^ word
-	|	var_name COLON wspace* LPAREN? os=explicit_arithmetic RPAREN? (COLON len=explicit_arithmetic)? -> ^(OFFSET var_name $os ^($len)?)
+	|	var_name COLON wspace* os=explicit_arithmetic (COLON len=explicit_arithmetic)? -> ^(OFFSET var_name $os ^($len)?)
 	|	BANG^ var_name (TIMES|AT)
 	|	BANG var_name LSQUARE (op=TIMES|op=AT) RSQUARE -> ^(LIST_EXPAND var_name $op)
 	|	BANG var_name -> ^(VAR_REF var_name)
 	|	var_name (POUND^|POUNDPOUND^) fname
 	|	var_name (PCT^|PCTPCT^) fname
-	|	var_name SLASH POUND ns_str SLASH fname -> ^(REPLACE_FIRST var_name ns_str fname)
-	| 	var_name SLASH PCT ns_str SLASH fname -> ^(REPLACE_LAST var_name ns_str fname)
-	|	var_name SLASH SLASH ns_str SLASH fname -> ^(REPLACE_ALL var_name ns_str fname)
-	|	var_name SLASH SLASH ns_str SLASH? -> ^(REPLACE_ALL var_name ns_str)
-	|	var_name SLASH ns_str SLASH fname -> ^(REPLACE_FIRST var_name ns_str fname)
-	|	var_name SLASH POUND ns_str SLASH? -> ^(REPLACE_FIRST var_name ns_str)
-	|	var_name SLASH PCT ns_str SLASH? -> ^(REPLACE_LAST var_name ns_str)
-	|	var_name SLASH ns_str SLASH? -> ^(REPLACE_FIRST var_name ns_str)
+	|	var_name parameter_replace_operator^ ns_str parameter_replace_string
 	|	arr_var_ref
 	|	var_size_ref
 	|	var_name
 	|	TIMES
 	|	AT;
+parameter_replace_string
+	:	(SLASH fname|SLASH)? -> fname?;
+parameter_replace_operator
+	:	SLASH SLASH -> REPLACE_ALL
+	|	SLASH PCT -> REPLACE_LAST
+	|	SLASH POUND -> REPLACE_FIRST
+	|	SLASH -> REPLACE_FIRST;
 //Allowable variable names in the variable expansion
 var_name:	num|name|POUND;
 //Referencing an array variable



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-12  7:19 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-12  7:19 UTC (permalink / raw
  To: gentoo-commits

commit:     c7c59452375df8fcd408785e422c53035b141ebd
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Mon Apr 11 17:42:10 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Apr 12 06:23:31 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=c7c59452

Refactor nqstr rule for readability

Move each alternative to own line, rename to nsqrt_part and move the
plus operator the callers. This should make the rule easier to read.

---
 bashast/bashast.g |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 6148318..510ef90 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -367,12 +367,23 @@ ns_str	:	ns_str_part* -> ^(STRING ns_str_part*);
 fname	:	fname_part+ -> ^(STRING fname_part+);
 //A string that is NOT a bash reserved word
 fname_no_res_word
-	:	nqstr fname_part* -> ^(STRING nqstr fname_part*);
+	:	nqstr_part+ fname_part* -> ^(STRING nqstr_part+ fname_part*);
 fname_part
-	:	nqstr
+	:	nqstr_part+
 	|	res_word_str;
-//non-quoted string rule, allows expansions
-nqstr	:	(bracket_pattern_match|extended_pattern_match|var_ref|command_sub|arithmetic_expansion|brace_expansion|dqstr|sqstr|(str_part str_part_with_pound*)|pattern_match_trigger|BANG)+;
+//non-quoted string part rule, allows expansions
+nqstr_part
+	:	bracket_pattern_match
+	|	extended_pattern_match
+	|	var_ref
+	|	command_sub
+	|	arithmetic_expansion
+	|	brace_expansion
+	|	dqstr
+	|	sqstr
+	|	str_part str_part_with_pound*
+	|	pattern_match_trigger
+	|	BANG;
 //double quoted string rule, allows expansions
 dqstr	:	QUOTE dqstr_part* QUOTE -> ^(DOUBLE_QUOTED_STRING dqstr_part*);
 dqstr_part



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-12 18:29 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-12 18:29 UTC (permalink / raw
  To: gentoo-commits

commit:     284f2fd1149453021d518b9cb2665103715df409
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 12 11:19:32 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Apr 12 12:08:11 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=284f2fd1

Fix broken grammar for test ebuilds

Binary arithmetic is broken by some previous commits. Now it's
fixed.

---
 bashast/bashast.g       |    2 +-
 bashast/libbashWalker.g |    8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 9f0f80c..0defc93 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -435,7 +435,7 @@ pre_inc_dec
 	|	MINUS MINUS BLANK? primary -> ^(PRE_DECR primary);
 unary	:	post_inc_dec
 	|	pre_inc_dec
-	|	primary
+	|	BLANK!? primary
 	|	PLUS unary -> ^(PLUS_SIGN unary)
 	|	MINUS unary -> ^(MINUS_SIGN unary)
 	|	(TILDE|BANG)^ unary;

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index e0add2a..33c18a6 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -160,10 +160,10 @@ arithmetics returns[int value]
 	|^(VAR_REF libbash_name=name) {
 		$value = walker->resolve<int>(libbash_name);
 	}
-	|^(PRE_INCR libbash_name=name){ $value = walker->pre_incr(libbash_name); }
-	|^(PRE_DECR libbash_name=name){ $value = walker->pre_decr(libbash_name); }
-	|^(POST_INCR libbash_name=name){ $value = walker->post_incr(libbash_name); }
-	|^(POST_DECR libbash_name=name){ $value = walker->post_decr(libbash_name); }
+	|^(PRE_INCR ^(VAR_REF libbash_name=name)){ $value = walker->pre_incr(libbash_name); }
+	|^(PRE_DECR ^(VAR_REF libbash_name=name)){ $value = walker->pre_decr(libbash_name); }
+	|^(POST_INCR ^(VAR_REF libbash_name=name)){ $value = walker->post_incr(libbash_name); }
+	|^(POST_DECR ^(VAR_REF libbash_name=name)){ $value = walker->post_decr(libbash_name); }
 	|^(EQUALS libbash_name=name l=arithmetics) {
 		$value = walker->set_value(libbash_name, l);
 	}



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-14  4:50 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-14  4:50 UTC (permalink / raw
  To: gentoo-commits

commit:     780f074ebcfcb77add12be018c84ee6126a3daee
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 14 01:11:41 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Apr 14 01:13:02 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=780f074e

Move functions to @member section

It's more proper to declare functions in @member section rather
than @postinclude section. Blank lines are added for better
readability.

---
 bashast/libbashWalker.g |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index b5e9974..9a3b7f2 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -26,23 +26,30 @@ options
 }
 
 @includes{
+
 #include <memory>
 #include <string>
 
 class interpreter;
 void set_interpreter(std::shared_ptr<interpreter> w);
+
 }
+
 @postinclude{
+
 #include "core/interpreter.h"
 #include <boost/format.hpp>
+
+}
+
+@members{
+
 static std::shared_ptr<interpreter> walker;
+
 void set_interpreter(std::shared_ptr<interpreter> w)
 {
 	walker = w;
 }
-}
-
-@members{
 
 inline void set_index(const std::string& name, unsigned& index, int value)
 {



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-20 11:26 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-20 11:26 UTC (permalink / raw
  To: gentoo-commits

commit:     806405efb29840b6d7eff3af5ec6dd41762d9f60
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Apr 16 19:22:14 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 11:22:36 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=806405ef

Parser: fix warnings from command_sub rule

---
 bashast/bashast.g |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index d0b9926..b69d2c5 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -168,8 +168,8 @@ brace_expansion_part
 	|	-> EMPTY_BRACE_EXPANSION_ATOM;
 commasep:	brace_expansion_part(COMMA! brace_expansion_part)+;
 command_sub
-	:	DOLLAR LPAREN BLANK* pipeline BLANK? RPAREN -> ^(COMMAND_SUB pipeline)
-	|	TICK BLANK* pipeline BLANK? TICK -> ^(COMMAND_SUB pipeline) ;
+	:	DOLLAR LPAREN pipeline BLANK? RPAREN -> ^(COMMAND_SUB pipeline)
+	|	TICK pipeline BLANK? TICK -> ^(COMMAND_SUB pipeline) ;
 //compound commands
 compound_command
 	:	for_expr



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-20 11:26 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-20 11:26 UTC (permalink / raw
  To: gentoo-commits

commit:     77a830f8994b54f4f13eb5f11cd690cfdb0c98d4
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Apr 16 19:38:59 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 11:22:37 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=77a830f8

Parser: fix warnings from time rule

---
 bashast/bashast.g |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 03678bd..0842f54 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -111,7 +111,7 @@ command_separator
 	|	EOL!;
 pipeline
 	:	BLANK!* time? ((BANG) => (BANG BLANK!+))? command^ (BLANK!* PIPE^ BLANK!* command)*;
-time	:	TIME^ BLANK!+ time_posix?;
+time	:	TIME^ BLANK!+ ((time_posix) => time_posix)?;
 time_posix
 	:	TIME_POSIX BLANK!+;
 //The structure of a command in bash



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-20 11:26 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-20 11:26 UTC (permalink / raw
  To: gentoo-commits

commit:     5e00bd73e5ea85926befbdc155375161b51cbd07
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Apr 16 19:29:07 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 11:22:37 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=5e00bd73

Parser: fix warning from pipeline rule

---
 bashast/bashast.g |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index b69d2c5..03678bd 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -110,7 +110,7 @@ command_separator
 	|	AMP^
 	|	EOL!;
 pipeline
-	:	BLANK!* time? (BANG BLANK!+)? command^ (BLANK!* PIPE^ BLANK!* command)*;
+	:	BLANK!* time? ((BANG) => (BANG BLANK!+))? command^ (BLANK!* PIPE^ BLANK!* command)*;
 time	:	TIME^ BLANK!+ time_posix?;
 time_posix
 	:	TIME_POSIX BLANK!+;



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-20 11:26 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-20 11:26 UTC (permalink / raw
  To: gentoo-commits

commit:     097660eedfce9087b52a39f76264dde759208117
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Tue Apr 19 16:36:02 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 11:22:37 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=097660ee

Parser: improve arithmetic white space handling

We don't have to list blank on both sides of operators. Now the code
follows the rule of always looking at white space after operators.

---
 bashast/bashast.g |   32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 9c32d58..6612dbc 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -470,15 +470,15 @@ extended_pattern_match
 //the square bracket from is deprecated
 //http://permalink.gmane.org/gmane.comp.shells.bash.bugs/14479
 arithmetic_expansion
-	:	DOLLAR LLPAREN BLANK* arithmetics BLANK* RRPAREN -> ^(ARITHMETIC_EXPRESSION arithmetics)
-	|	DOLLAR LSQUARE BLANK* arithmetics BLANK* RSQUARE -> ^(ARITHMETIC_EXPRESSION arithmetics);
+	:	DOLLAR LLPAREN BLANK* arithmetics RRPAREN -> ^(ARITHMETIC_EXPRESSION arithmetics)
+	|	DOLLAR LSQUARE BLANK* arithmetics RSQUARE -> ^(ARITHMETIC_EXPRESSION arithmetics);
 //explicit arithmetic in places like array indexes
 explicit_arithmetic
-	:	(DOLLAR LLPAREN BLANK*)? arithmetics (BLANK* RRPAREN)? -> arithmetics
-	|	(DOLLAR LSQUARE BLANK*)? arithmetics (BLANK* RSQUARE)? -> arithmetics;
+	:	(DOLLAR LLPAREN BLANK*)? arithmetics RRPAREN? -> arithmetics
+	|	(DOLLAR LSQUARE BLANK*)? arithmetics RSQUARE? -> arithmetics;
 //The comma operator for arithmetic expansions
 arithmetics
-	:	arithmetic (BLANK!* COMMA! BLANK!* arithmetic)*;
+	:	arithmetic (COMMA! BLANK!* arithmetic)*;
 arithmetic
 	:	arithmetic_condition
 	|	arithmetic_assignment;
@@ -498,25 +498,25 @@ pre_inc_dec
 	|	MINUS MINUS BLANK? primary -> ^(PRE_DECR primary);
 unary	:	post_inc_dec
 	|	pre_inc_dec
-	|	primary
+	|	primary BLANK!*
 	|	PLUS BLANK* unary -> ^(PLUS_SIGN unary)
 	|	MINUS BLANK* unary -> ^(MINUS_SIGN unary)
 	|	(TILDE|BANG)^ BLANK!* unary;
 exponential
-	:	unary (BLANK!* EXP^ BLANK!* unary)* ;
+	:	unary (EXP^ BLANK!* unary)* ;
 times_division_modulus
-	:	exponential (BLANK!* (TIMES^|SLASH^|PCT^) BLANK!* exponential)*;
-addsub	:	times_division_modulus (BLANK!* (PLUS^|MINUS^)BLANK!* times_division_modulus)*;
-shifts	:	addsub (BLANK!* (LSHIFT^|RSHIFT^) BLANK!* addsub)*;
-compare	:	shifts (BLANK!* (LEQ^|GEQ^|LESS_THAN^|GREATER_THAN^)BLANK!* shifts)?;
+	:	exponential ((TIMES^|SLASH^|PCT^) BLANK!* exponential)*;
+addsub	:	times_division_modulus ((PLUS^|MINUS^) BLANK!* times_division_modulus)*;
+shifts	:	addsub ((LSHIFT^|RSHIFT^) BLANK!* addsub)*;
+compare	:	shifts ((LEQ^|GEQ^|LESS_THAN^|GREATER_THAN^) BLANK!* shifts)?;
 bitwiseand
-	:	compare (BLANK!* AMP^ BLANK!* compare)*;
+	:	compare (AMP^ BLANK!* compare)*;
 bitwisexor
-	:	bitwiseand (BLANK!* CARET^ BLANK!* bitwiseand)*;
+	:	bitwiseand (CARET^ BLANK!* bitwiseand)*;
 bitwiseor
-	:	bitwisexor (BLANK!* PIPE^ BLANK!* bitwisexor)*;
-logicand:	bitwiseor (BLANK!* LOGICAND^ BLANK!* bitwiseor)*;
-logicor	:	logicand (BLANK!* LOGICOR^ BLANK!* logicand)*;
+	:	bitwisexor (PIPE^ BLANK!* bitwisexor)*;
+logicand:	bitwiseor (LOGICAND^ BLANK!* bitwiseor)*;
+logicor	:	logicand (LOGICOR^ BLANK!* logicand)*;
 
 arithmetic_condition
 	:	cnd=logicor QMARK t=logicor COLON f=logicor -> ^(ARITHMETIC_CONDITION $cnd $t $f);



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-20 11:26 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-20 11:26 UTC (permalink / raw
  To: gentoo-commits

commit:     32caed8c181850f4169b1b78beb72e63432feccc
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Tue Apr 19 16:49:23 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 11:22:48 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=32caed8c

Parser: fix warnings from array_atom rule

---
 bashast/bashast.g |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index a2b176d..9916662 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -235,7 +235,7 @@ value	:	fname
 arr_val	:
 	|	(ag+=array_atom wspace*)+ -> ^(ARRAY $ag+);
 array_atom
-	:	LSQUARE! BLANK!* explicit_arithmetic BLANK!? RSQUARE! EQUALS^ fname
+	:	(LSQUARE) => LSQUARE! BLANK!* explicit_arithmetic BLANK!? RSQUARE! EQUALS^ fname
 	|	fname;
 //Referencing a variable (different possible ways/special parameters)
 var_ref



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-20 11:26 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-20 11:26 UTC (permalink / raw
  To: gentoo-commits

commit:     68bde36d19b2acf43e26ba9c976ff8f5bee315c8
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Tue Apr 19 16:40:18 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 11:22:48 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=68bde36d

Parser: reorder arithmetic rules

Reorder arithmetic expansion related rules so that they flow logically
from top to bottom. Previously some first rules came at the top and then
it jumped to the bottom of the recursion.

---
 bashast/bashast.g |   33 +++++++++++++++++----------------
 1 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 6612dbc..d789acd 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -466,22 +466,6 @@ extended_pattern_match
 	|	PLUS LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_AT_LEAST_ONE fname+)
 	|	AT LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_EXACTLY_ONE fname+)
 	|	BANG LPAREN fname (PIPE fname)* RPAREN -> ^(MATCH_NONE fname+);
-//Arithmetic expansion
-//the square bracket from is deprecated
-//http://permalink.gmane.org/gmane.comp.shells.bash.bugs/14479
-arithmetic_expansion
-	:	DOLLAR LLPAREN BLANK* arithmetics RRPAREN -> ^(ARITHMETIC_EXPRESSION arithmetics)
-	|	DOLLAR LSQUARE BLANK* arithmetics RSQUARE -> ^(ARITHMETIC_EXPRESSION arithmetics);
-//explicit arithmetic in places like array indexes
-explicit_arithmetic
-	:	(DOLLAR LLPAREN BLANK*)? arithmetics RRPAREN? -> arithmetics
-	|	(DOLLAR LSQUARE BLANK*)? arithmetics RSQUARE? -> arithmetics;
-//The comma operator for arithmetic expansions
-arithmetics
-	:	arithmetic (COMMA! BLANK!* arithmetic)*;
-arithmetic
-	:	arithmetic_condition
-	|	arithmetic_assignment;
 //The base of the arithmetic operator.  Used for order of operations
 arithmetic_var_ref:
 	var_ref -> ^(VAR_REF var_ref);
@@ -526,6 +510,23 @@ arithmetic_assignment_opterator
 
 arithmetic_assignment
 	:	((var_name_no_digit|arithmetic_var_ref) BLANK!* arithmetic_assignment_opterator^ BLANK!*)? logicor;
+arithmetic
+	:	arithmetic_condition
+	|	arithmetic_assignment;
+//The comma operator for arithmetic expansions
+arithmetics
+	:	arithmetic (COMMA! BLANK!* arithmetic)*;
+//explicit arithmetic in places like array indexes
+explicit_arithmetic
+	:	(DOLLAR LLPAREN BLANK*)? arithmetics RRPAREN? -> arithmetics
+	|	(DOLLAR LSQUARE BLANK*)? arithmetics RSQUARE? -> arithmetics;
+//Arithmetic expansion
+//the square bracket from is deprecated
+//http://permalink.gmane.org/gmane.comp.shells.bash.bugs/14479
+arithmetic_expansion
+	:	DOLLAR LLPAREN BLANK* arithmetics RRPAREN -> ^(ARITHMETIC_EXPRESSION arithmetics)
+	|	DOLLAR LSQUARE BLANK* arithmetics RSQUARE -> ^(ARITHMETIC_EXPRESSION arithmetics);
+
 process_substitution
 	:	(dir=LESS_THAN|dir=GREATER_THAN)LPAREN clist BLANK* RPAREN -> ^(PROCESS_SUBSTITUTION $dir clist);
 //the biggie: functions



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-20 11:26 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-20 11:26 UTC (permalink / raw
  To: gentoo-commits

commit:     a404d5b6392cb732cb7ec9c811303c92980e39ca
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Tue Apr 19 16:42:09 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 11:22:48 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=a404d5b6

Parser: typo fix opterator to operator

---
 bashast/bashast.g |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index d789acd..a2b176d 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -505,11 +505,11 @@ logicor	:	logicand (LOGICOR^ BLANK!* logicand)*;
 arithmetic_condition
 	:	cnd=logicor QMARK t=logicor COLON f=logicor -> ^(ARITHMETIC_CONDITION $cnd $t $f);
 
-arithmetic_assignment_opterator
+arithmetic_assignment_operator
 	:	EQUALS|MUL_ASSIGN|DIVIDE_ASSIGN|MOD_ASSIGN|PLUS_ASSIGN|MINUS_ASSIGN|LSHIFT_ASSIGN|RSHIFT_ASSIGN|AND_ASSIGN|XOR_ASSIGN|OR_ASSIGN;
 
 arithmetic_assignment
-	:	((var_name_no_digit|arithmetic_var_ref) BLANK!* arithmetic_assignment_opterator^ BLANK!*)? logicor;
+	:	((var_name_no_digit|arithmetic_var_ref) BLANK!* arithmetic_assignment_operator^ BLANK!*)? logicor;
 arithmetic
 	:	arithmetic_condition
 	|	arithmetic_assignment;



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-20 11:26 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-20 11:26 UTC (permalink / raw
  To: gentoo-commits

commit:     5641e7417ffed007581d9f811985dae7fdd81ef8
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Tue Apr 19 18:38:58 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Apr 20 11:22:48 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=5641e741

Parser: Left-factor variable expansion

There was a lot of bactracking going on in the var_exp rule.
Left-factoring brings down versionator memory usage from around 1 GB to
200 MB.

---
 bashast/bashast.g |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 9916662..61c5914 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -249,15 +249,24 @@ var_ref
 	|	DOLLAR MINUS -> ^(VAR_REF MINUS)
 	|	DOLLAR BANG -> ^(VAR_REF BANG);
 //Variable expansions
-var_exp	:	var_name parameter_value_operator^ word
-	|	var_name COLON wspace* os=explicit_arithmetic (COLON len=explicit_arithmetic)? -> ^(OFFSET var_name $os ^($len)?)
-	|	BANG^ var_name_for_bang (TIMES|AT)
-	|	BANG var_name_for_bang LSQUARE (op=TIMES|op=AT) RSQUARE -> ^(LIST_EXPAND var_name_for_bang $op)
-	|	BANG var_name_for_bang -> ^(VAR_REF var_name_for_bang)
-	|	var_name parameter_delete_operator parameter_pattern_part+ -> ^(parameter_delete_operator var_name ^(STRING parameter_pattern_part+))
-	|	var_name parameter_replace_operator^ parameter_replace_pattern parameter_replace_string
+var_exp	:	var_name (
+				  parameter_value_operator word
+					-> ^(parameter_value_operator var_name word)
+				| COLON wspace* os=explicit_arithmetic (COLON len=explicit_arithmetic)?
+					-> ^(OFFSET var_name $os ^($len)?)
+				| parameter_delete_operator parameter_pattern_part+
+					-> ^(parameter_delete_operator var_name ^(STRING parameter_pattern_part+))
+				| parameter_replace_operator parameter_replace_pattern parameter_replace_string
+					-> ^(parameter_replace_operator var_name parameter_replace_pattern parameter_replace_string?)
+				| -> var_name
+			 )
+	|	BANG var_name_for_bang  (
+					   TIMES -> ^(BANG var_name_for_bang TIMES)
+					 | AT -> ^(BANG var_name_for_bang AT)
+					 | LSQUARE (op=TIMES|op=AT) RSQUARE -> ^(LIST_EXPAND var_name_for_bang $op)
+					 | -> ^(VAR_REF var_name_for_bang)
+					)
 	|	var_size_ref
-	|	var_name
 	|	TIMES
 	|	AT;
 parameter_delete_operator



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-21  7:55 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-21  7:55 UTC (permalink / raw
  To: gentoo-commits

commit:     cbb62a2dd0c8a09c220b84832fb004977880050c
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Wed Apr 20 15:20:16 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Apr 21 07:53:24 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=cbb62a2d

Parser: turn on memoize

The massif and benchmark_parser make targets show that we benefit
greatly from turning on memoization.

---
 bashast/bashast.g |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 21bbad4..f6e50b3 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -23,6 +23,7 @@ options
 	output	= AST;
 	language	= Java;
 	ASTLabelType	= CommonTree;
+	memoize		= true;
 }
 tokens{
 	ARG;



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-04-27 15:11 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-04-27 15:11 UTC (permalink / raw
  To: gentoo-commits

commit:     cab98c13280a953bc5cedb911dae493b74c8093c
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 24 12:28:21 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Mon Apr 25 10:07:50 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=cab98c13

Walker: change the implementation of index searching

We used recursive counting algorithm to find the index of LT(2).
Now it's changed to recurrence algorithm that directly traverse the
input stream. This can benefit function definition and compound
command.

---
 bashast/libbashWalker.g |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index b6123d9..a3bf40d 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -64,24 +64,27 @@ options
 		index = value;
 	}
 
-	// Recursively count number of nodes of curr
-	static int count_nodes(pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_BASE_TREE curr)
+	// seek to LT(2) and consume
+	static void seek_to_next_tree(plibbashWalker ctx)
 	{
-		int child_count = adaptor->getChildCount(adaptor, curr);
-		if(child_count == 0)
-		{
-			// Leaf node
-			return 1;
-		}
-		else
+		// We start from LA(1)
+		int index = 1;
+		// Current depth of the tree we are traversing
+		int depth = 1;
+
+		for(index = 1; depth != 0; ++index)
 		{
-			int result = 0;
-			// Count every child
-			for(int i = 0; i != child_count; ++i)
-				result += count_nodes(adaptor, (pANTLR3_BASE_TREE)(adaptor->getChild(adaptor, curr, i)));
-			// Add itself, DOWN and UP
-			return result + 3;
+			// Go one level done if we encounter DOWN
+			if(LA(index) == DOWN)
+				++depth;
+			// Go one level up if we encounter UP. When depth==0, we finishe one node
+			else if(LA(index) == UP)
+				--depth;
 		}
+
+		// Seek to the correct offset and consume.
+		SEEK(INDEX() + index - 3);
+		CONSUME();
 	}
 
 }
@@ -324,11 +327,8 @@ function_def returns[int placeholder]
 	:^(FUNCTION ^(STRING name) {
 		// Define the function with current index
 		walker->define_function($name.libbash_value, INDEX());
-		// Skip the AST for function body, minus one is needed to make the offset right.
-		// LT(1) is the function body. It should match the compound_command rule.
-		SEEK(INDEX() + count_nodes(ADAPTOR, LT(1)) - 1);
-		// After seeking ahead, we need to call CONSUME to eat all the nodes we've skipped.
-		CONSUME();
+		// Skip the AST for function body
+		seek_to_next_tree(ctx);
 	});
 
 // Only used in arithmetic expansion



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-05-12 14:06 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-05-12 14:06 UTC (permalink / raw
  To: gentoo-commits

commit:     99b73edf438b515b933d67827d4816a0ba0b0f9d
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Wed May 11 09:17:24 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed May 11 09:17:24 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=99b73edf

Walker: reimplement bracket pattern

With the help of dynamic regular expressions, we can easily build
bracket pattern with little manual parsing work.

---
 bashast/libbashWalker.g |   36 ++++--------------------------------
 1 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 307333d..6c9e0c1 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -228,41 +228,13 @@ bash_pattern[boost::xpressive::sregex& pattern, bool greedy]
 		|(MATCH_ANY_EXCEPT|MATCH_ANY) =>
 		^((MATCH_ANY_EXCEPT { negation = true; } | MATCH_ANY { negation = false; })
 		  (s=string_part { pattern_str += s.libbash_value; })+) {
-			if(pattern_str.empty())
-				return;
-
-			// deal with the first character specially
-			int index = 0;
-			auto char_set = set = as_xpr(pattern_str[0]);
-			if( index + 1 < pattern_str.size() && pattern_str[index + 1] == '-')
-			{
-				char_set = set[range(pattern_str[index], pattern_str[index + 2])];
-				index += 3;
-			}
-			else
-			{
-				++index;
-			}
-
-			// handle all characters in the pattern
-			while(index < pattern_str.size())
-			{
-				if( index + 1 < pattern_str.size() && pattern_str[index + 1] == '-')
-				{
-					char_set |= range(pattern_str[index], pattern_str[index + 2]);
-					index += 3;
-				}
-				else
-				{
-					char_set |= pattern_str[index];
-					++index;
-				}
-			}
 
 			if(negation)
-				append($pattern, ~char_set, do_append);
+				pattern_str = "[^" + pattern_str + "]";
 			else
-				append($pattern, char_set, do_append);
+				pattern_str = "[" + pattern_str + "]";
+
+			append($pattern, sregex::compile(pattern_str), do_append);
 		}
 		|(libbash_string=any_string {
 			append($pattern, as_xpr(libbash_string), do_append);



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-05-22 21:00 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-05-22 21:00 UTC (permalink / raw
  To: gentoo-commits

commit:     0c2ef440b8432ed9f56f9ccd416b3a242beac5ae
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Thu May 19 08:25:19 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun May 22 20:43:21 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=0c2ef440

Parser: move LOCAL token to ns_str_part

"local" is not a reserved word so it shouldn't be put to res_word_str.
Now it's moved to ns_str_part.

---
 bashast/bashast.g |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 48ae78d..e391a35 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -396,7 +396,7 @@ options{k=1;backtrack=false;}
 	:	DIGIT|NUMBER;
 //A rule for filenames/strings
 res_word_str
-	:	CASE|DO|DONE|ELIF|ELSE|ESAC|FI|FOR|FUNCTION|IF|IN|SELECT|THEN|UNTIL|WHILE|TIME|LOCAL;
+	:	CASE|DO|DONE|ELIF|ELSE|ESAC|FI|FOR|FUNCTION|IF|IN|SELECT|THEN|UNTIL|WHILE|TIME;
 //Any allowable part of a string, including slashes, no pounds
 str_part
 	:	ns_str_part
@@ -412,7 +412,7 @@ ns_str_part
 	|OTHER|EQUALS|PCT|PCTPCT|MINUS|DOT|DOTDOT|COLON|TEST_EXPR
 	|TILDE|MUL_ASSIGN|DIVIDE_ASSIGN|MOD_ASSIGN|PLUS_ASSIGN|MINUS_ASSIGN
 	|TIME_POSIX|LSHIFT_ASSIGN|RSHIFT_ASSIGN|AND_ASSIGN|XOR_ASSIGN
-	|OR_ASSIGN|CARET|POUND|POUNDPOUND|COMMA|EXPORT;
+	|OR_ASSIGN|CARET|POUND|POUNDPOUND|COMMA|EXPORT|LOCAL;
 
 //Generic strings/filenames.
 fname	:	(~POUND) => fname_part fname_part* -> ^(STRING fname_part+);



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-05-29 11:20 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-05-29 11:20 UTC (permalink / raw
  To: gentoo-commits

commit:     86299ea48f38459fa038a5c9aca1bc6d3b24f7a6
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri May 27 14:06:19 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun May 29 11:44:52 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=86299ea4

Walker: rename command_index to condition_index

---
 bashast/libbashWalker.g |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 39b84c5..f2fba4a 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -690,21 +690,21 @@ for_modification
 
 while_expr
 @declarations {
-	ANTLR3_MARKER command_index;
+	ANTLR3_MARKER condition_index;
 	bool negate;
 }
 	:^((WHILE { negate = false; } | UNTIL { negate = true; }) {
 		// omit the first DOWN token
 		SEEK(INDEX() + 1);
 
-		command_index = INDEX();
+		condition_index = INDEX();
 		while(true)
 		{
 			command_list(ctx);
 			if(walker->get_status() == (negate? 0 : 1))
 				break;
 			command_list(ctx);
-			SEEK(command_index);
+			SEEK(condition_index);
 		}
 		// Skip the body and get out
 		seek_to_next_tree(ctx);



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-05-29 11:20 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-05-29 11:20 UTC (permalink / raw
  To: gentoo-commits

commit:     fb30f68e903cf62eb02caa3c8784c57431916ef5
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Sun May 29 01:46:08 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sun May 29 11:44:53 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=fb30f68e

Parser&Walker: use EOF as the end of grammar

This change is hard to get tested. Eclasses now fail to parse if the
parsers stop too early.

---
 bashast/bashast.g       |    2 +-
 bashast/libbashWalker.g |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index bb12b91..f9d5425 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -104,7 +104,7 @@ tokens{
 	NOT_EQUALS;
 }
 
-start	:	(flcomment)? EOL* clist BLANK* (SEMIC|AMP|EOL)? -> clist;
+start	:	(flcomment)? EOL* clist BLANK* (SEMIC|AMP|EOL)? EOF -> clist;
 //Because the comment token doesn't handle the first comment in a file if it's on the first line, have a parser rule for it
 flcomment
 	:	POUND ~(EOL)* EOL;

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index e61d7b6..f53a2be 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -116,7 +116,7 @@ options
 	}
 }
 
-start: list|EOF;
+start: list EOF;
 
 list: ^(LIST (logic_command_list)+);
 



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-06-11  8:52 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-06-11  8:52 UTC (permalink / raw
  To: gentoo-commits

commit:     500e3427ff9ec64473f052e8c11a992d34f5e09f
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 10 08:30:05 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Jun 11 08:09:12 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=500e3427

Walker: use namespace instead of static functions

We removed the inline keyword as compiler will do it when proper
optimization level/flag is on.

---
 bashast/libbashWalker.g |  137 ++++++++++++++++++++++++-----------------------
 1 files changed, 70 insertions(+), 67 deletions(-)

diff --git a/bashast/libbashWalker.g b/bashast/libbashWalker.g
index 5587bfa..962a57d 100644
--- a/bashast/libbashWalker.g
+++ b/bashast/libbashWalker.g
@@ -62,84 +62,87 @@ options
 		walker = w;
 	}
 
-	inline void set_index(const std::string& name, unsigned& index, int value)
+	namespace
 	{
-		if(value < 0)
-			throw interpreter_exception((boost::format("Array index is less than 0: \%s[\%d]") \% name \% value).str());
-		index = value;
-	}
-
-	// seek to LT(2) and consume
-	static void seek_to_next_tree(plibbashWalker ctx)
-	{
-		// Current depth of the tree we are traversing
-		int depth = 1;
-
-		// The beginning should always be ROOT DOWN ANY_TOKEN
-		// So we start from LA(4)
-		int index = 4;
-		for(; depth != 0; ++index)
+		void set_index(const std::string& name, unsigned& index, int value)
 		{
-			// Go one level done if we encounter DOWN
-			if(LA(index) == DOWN)
-				++depth;
-			// Go one level up if we encounter UP. When depth==0, we finishe one node
-			else if(LA(index) == UP)
-				--depth;
+			if(value < 0)
+				throw interpreter_exception((boost::format("Array index is less than 0: \%s[\%d]") \% name \% value).str());
+			index = value;
 		}
 
-		// Seek to the correct offset and consume.
-		SEEK(INDEX() + index - 2);
-		CONSUME();
-	}
-
-	// The method is used to append a pattern with another one. Because it's not allowed to append an empty pattern,
-	// we need the argument 'do_append' to indicate whether the pattern is empty. 'do_append' will be set to true after
-	// the first assignment.
-	inline void append(boost::xpressive::sregex& pattern, const boost::xpressive::sregex& new_pattern, bool& do_append)
-	{
-		using namespace boost::xpressive;
-		if(do_append)
+		// seek to LT(2) and consume
+		void seek_to_next_tree(plibbashWalker ctx)
 		{
-			pattern = sregex(pattern >> new_pattern);
+			// Current depth of the tree we are traversing
+			int depth = 1;
+
+			// The beginning should always be ROOT DOWN ANY_TOKEN
+			// So we start from LA(4)
+			int index = 4;
+			for(; depth != 0; ++index)
+			{
+				// Go one level done if we encounter DOWN
+				if(LA(index) == DOWN)
+					++depth;
+				// Go one level up if we encounter UP. When depth==0, we finishe one node
+				else if(LA(index) == UP)
+					--depth;
+			}
+
+			// Seek to the correct offset and consume.
+			SEEK(INDEX() + index - 2);
+			CONSUME();
 		}
-		else
+
+		// The method is used to append a pattern with another one. Because it's not allowed to append an empty pattern,
+		// we need the argument 'do_append' to indicate whether the pattern is empty. 'do_append' will be set to true after
+		// the first assignment.
+		void append(boost::xpressive::sregex& pattern, const boost::xpressive::sregex& new_pattern, bool& do_append)
 		{
-			pattern = new_pattern;
-			do_append = true;
+			using namespace boost::xpressive;
+			if(do_append)
+			{
+				pattern = sregex(pattern >> new_pattern);
+			}
+			else
+			{
+				pattern = new_pattern;
+				do_append = true;
+			}
 		}
-	}
 
-	bool match(const std::string& target,
-			   const boost::xpressive::sregex& pattern)
-	{
-	  return boost::xpressive::regex_match(target, pattern);
-	}
+		bool match(const std::string& target,
+				   const boost::xpressive::sregex& pattern)
+		{
+		  return boost::xpressive::regex_match(target, pattern);
+		}
 
-	/// \brief parse the text value of a tree to integer
-	/// \param the target tree
-	/// \return the parsed value
-	static int parse_int(ANTLR3_BASE_TREE* tree)
-	{
-		return tree->getText(tree)->toInt32(tree->getText(tree));
-	}
+		/// \brief parse the text value of a tree to integer
+		/// \param the target tree
+		/// \return the parsed value
+		int parse_int(ANTLR3_BASE_TREE* tree)
+		{
+			return tree->getText(tree)->toInt32(tree->getText(tree));
+		}
 
-	/// \brief a helper function that get the string value
-	///        of the given pANTLR3_BASE_TREE node.
-	/// \param the target tree node
-	/// \return the value of node->text
-	static std::string get_string(pANTLR3_BASE_TREE node)
-	{
-		pANTLR3_COMMON_TOKEN token = node->getToken(node);
-		// The tree walker may send null pointer here, so return an empty
-		// string if that's the case.
-		if(!token->start)
-			return "";
-		// Use reinterpret_cast here because we have to cast C code.
-		// The real type here is int64_t which is used as a pointer.
-		// token->stop - token->start + 1 should be bigger than 0.
-		return std::string(reinterpret_cast<const char *>(token->start),
-						   boost::numeric_cast<unsigned>(token->stop - token->start + 1));
+		/// \brief a helper function that get the string value
+		///        of the given pANTLR3_BASE_TREE node.
+		/// \param the target tree node
+		/// \return the value of node->text
+		std::string get_string(pANTLR3_BASE_TREE node)
+		{
+			pANTLR3_COMMON_TOKEN token = node->getToken(node);
+			// The tree walker may send null pointer here, so return an empty
+			// string if that's the case.
+			if(!token->start)
+				return "";
+			// Use reinterpret_cast here because we have to cast C code.
+			// The real type here is int64_t which is used as a pointer.
+			// token->stop - token->start + 1 should be bigger than 0.
+			return std::string(reinterpret_cast<const char *>(token->start),
+							   boost::numeric_cast<unsigned>(token->stop - token->start + 1));
+		}
 	}
 }
 



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-06-14  8:28 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-06-14  8:28 UTC (permalink / raw
  To: gentoo-commits

commit:     42eb1d5a0261113e2f14786d1678cc0631c1e9a9
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Jun 11 11:20:07 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Sat Jun 11 11:20:07 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=42eb1d5a

Parser: remove redundant case_pattern rule

---
 bashast/bashast.g |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index fde2c7e..17e8fbb 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -222,12 +222,8 @@ case_expr
 case_body
 	:	case_stmt (wspace* DOUBLE_SEMIC case_stmt)* wspace* DOUBLE_SEMIC? wspace* -> case_stmt*;
 case_stmt
-	:	wspace* (LPAREN BLANK*)? case_pattern (BLANK* PIPE BLANK? case_pattern)* BLANK* RPAREN (wspace* clist)?
-		-> ^(CASE_PATTERN case_pattern+ (CASE_COMMAND clist)?);
-case_pattern
-	:	command_sub
-	|	fname
-	|	TIMES;
+	:	wspace* (LPAREN BLANK*)? fname (BLANK* PIPE BLANK? fname)* BLANK* RPAREN (wspace* clist)?
+		-> ^(CASE_PATTERN fname+ (CASE_COMMAND clist)?);
 //A grouping of commands executed in a subshell
 subshell:	LPAREN wspace? clist (BLANK* SEMIC)? (BLANK* EOL)* BLANK* RPAREN redirect? -> ^(SUBSHELL clist redirect?);
 //A grouping of commands executed in the current shell



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-06-14  8:28 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-06-14  8:28 UTC (permalink / raw
  To: gentoo-commits

commit:     6a4e03f76ea76077319e53f99ad4eb901cdc2763
Author:     Petteri Räty <petsku <AT> petteriraty <DOT> eu>
AuthorDate: Sat Jun 11 12:28:11 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Tue Jun 14 07:23:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=6a4e03f7

Parser: left factor bracket_pattern_match rule

---
 bashast/bashast.g |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 10e5556..24b94f7 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -455,12 +455,14 @@ pattern_match_trigger
 	|	AT;
 //Pattern matching using brackets
 bracket_pattern_match
-	:	LSQUARE RSQUARE (BANG|CARET) pattern_match RSQUARE -> ^(MATCH_ANY_EXCEPT RSQUARE pattern_match)
-	|	LSQUARE RSQUARE pattern_match RSQUARE -> ^(MATCH_ANY RSQUARE pattern_match)
-	|	LSQUARE (BANG|CARET) pattern_match RSQUARE -> ^(MATCH_ANY_EXCEPT pattern_match)
-	|	LSQUARE pattern_match RSQUARE -> ^(MATCH_ANY pattern_match)
+	:	LSQUARE! bracket_pattern_match_operator
 	|	TIMES -> MATCH_ALL
 	|	QMARK -> MATCH_ONE;
+bracket_pattern_match_operator
+	:	RSQUARE (BANG|CARET) pattern_match RSQUARE -> ^(MATCH_ANY_EXCEPT RSQUARE pattern_match)
+	|	RSQUARE              pattern_match RSQUARE -> ^(MATCH_ANY RSQUARE pattern_match)
+	|	(BANG|CARET)         pattern_match RSQUARE -> ^(MATCH_ANY_EXCEPT pattern_match)
+	|	                     pattern_match RSQUARE -> ^(MATCH_ANY pattern_match);
 pattern_match
 	:	pattern_match_atom+;
 //allowable patterns with bracket pattern matching



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

* [gentoo-commits] proj/libbash:master commit in: bashast/
@ 2011-06-26 13:38 Petteri Räty
  0 siblings, 0 replies; 45+ messages in thread
From: Petteri Räty @ 2011-06-26 13:38 UTC (permalink / raw
  To: gentoo-commits

commit:     46739350a7fc7dcd2b912742acd3b3e40655c277
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 16 05:04:56 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Thu Jun 16 05:04:56 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=46739350

Parser: remove the here_string_op rule

---
 bashast/bashast.g |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index fd626b7..0f297f6 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -149,7 +149,7 @@ export_item
 bash_command
 	:	fname_no_res_word (BLANK!+ fname)*;
 redirect:	(BLANK!* redirect_atom)*;
-redirect_atom:	here_string_op^ BLANK!* fname
+redirect_atom:	HERE_STRING_OP^ BLANK!* fname
 	|	here_doc_op^ BLANK!* fname EOL! heredoc
 	|	redir_op BLANK* redir_dest -> ^(REDIR redir_op redir_dest)
 	|	process_substitution;
@@ -160,8 +160,6 @@ file_desc_as_file
 	:	DIGIT -> ^(FILE_DESCRIPTOR DIGIT)
 	|	DIGIT MINUS -> ^(FILE_DESCRIPTOR_MOVE DIGIT);
 heredoc	:	(fname EOL!)*;
-here_string_op
-	:	HERE_STRING_OP;
 here_doc_op
 	:	LSHIFT MINUS -> OP["<<-"]
 	|	LSHIFT -> OP["<<"];



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

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

commit:     cd7ac69edee15151ad178fc075817d126e77fa21
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 20 11:52:21 2011 +0000
Commit:     Petteri Räty <betelgeuse <AT> gentoo <DOT> org>
CommitDate: Wed Jul 20 15:08:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=cd7ac69e

Parser: remove backtracking for double quoted string

---
 bashast/bashast.g |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 3ca2bf8..f712f2e 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -611,13 +611,12 @@ quoted_string
 double_quoted_string
 	:	DQUOTE double_quoted_string_part* DQUOTE -> ^(DOUBLE_QUOTED_STRING double_quoted_string_part*);
 double_quoted_string_part
-options{ backtrack = true; memoize = true; }
-	:	variable_reference
-	|	command_substitution
-	|	arithmetic_expansion
-	|	ESC DQUOTE -> DQUOTE
-	|	ESC TICK -> TICK
-	|	ESC DOLLAR -> DOLLAR
+	:	(DOLLAR (LBRACE|name|num|TIMES|AT|POUND|QMARK|MINUS|DOLLAR|BANG)) => variable_reference
+	|	(command_substitution) => command_substitution
+	|	(DOLLAR (LLPAREN|LSQUARE)) => arithmetic_expansion
+	|	(ESC DQUOTE) => ESC DQUOTE -> DQUOTE
+	|	(ESC TICK) => ESC TICK -> TICK
+	|	(ESC DOLLAR) => ESC DOLLAR -> DOLLAR
 	|	~(TICK|DQUOTE);
 
 string_part



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

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

commit:     3d46bb0d6f78c85ab50e19e9939dd341f98f79fe
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 27 02:40:07 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=3d46bb0d

Parser: put includes to more proper place

---
 bashast/bashast.g |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index bb70aec..2a0b23a 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -157,7 +157,8 @@ tokens{
 @includes {
 	C_INCLUDE #include <iostream>
 	C_INCLUDE #include <string>
-
+}
+@postinclude {
 	C_INCLUDE #include <boost/numeric/conversion/cast.hpp>
 
 	C_INCLUDE #include "core/exceptions.h"



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

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

commit:     f3a533ddaec1c7b7258145aea38ab698da8fb545
Author:     Mu Qiao <qiaomuf <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 26 15:00:55 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=f3a533dd

Parser: make the lexer code thread-safe

---
 bashast/bashast.g |   27 ++++++++++++++++++++++-----
 1 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/bashast/bashast.g b/bashast/bashast.g
index 9c248e4..bb70aec 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -127,18 +127,31 @@ tokens{
 	BUILTIN_LOGIC;
 }
 
-@lexer::members
+@lexer::context
 {
 #ifdef OUTPUT_C
-	bool double_quoted = false;
-#else
-	boolean double_quoted = false;
+	bool double_quoted;
+	int paren_level;
+#endif
+}
+
+@lexer::apifuncs
+{
+#ifdef OUTPUT_C
+	ctx->double_quoted = false;
+	ctx->paren_level = 0;
+#endif
+}
 
+@lexer::members
+{
+#ifndef OUTPUT_C
+	boolean double_quoted = false;
+	int paren_level = 0;
 	int LA(int index) {
 		return input.LA(index);
 	}
 #endif
-	int paren_level = 0;
 }
 #ifdef OUTPUT_C
 @includes {
@@ -149,6 +162,10 @@ tokens{
 
 	C_INCLUDE #include "core/exceptions.h"
 }
+@lexer::postinclude {
+	#define double_quoted ctx->double_quoted
+	#define paren_level ctx->paren_level
+}
 #endif
 @members
 {



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

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

Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-04 13:53 [gentoo-commits] proj/libbash:master commit in: bashast/ Petteri Räty
  -- strict thread matches above, loose matches on Subject: below --
2011-08-04 13:53 Petteri Räty
2011-08-04 13:53 Petteri Räty
2011-06-26 13:38 Petteri Räty
2011-06-14  8:28 Petteri Räty
2011-06-14  8:28 Petteri Räty
2011-06-11  8:52 Petteri Räty
2011-05-29 11:20 Petteri Räty
2011-05-29 11:20 Petteri Räty
2011-05-22 21:00 Petteri Räty
2011-05-12 14:06 Petteri Räty
2011-04-27 15:11 Petteri Räty
2011-04-21  7:55 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-20 11:26 Petteri Räty
2011-04-14  4:50 Petteri Räty
2011-04-12 18:29 Petteri Räty
2011-04-12  7:19 Petteri Räty
2011-04-12  7:19 Petteri Räty
2011-04-12  7:19 Petteri Räty
2011-04-11  6:50 Petteri Räty
2011-04-11  6:50 Petteri Räty
2011-04-09 13:08 Petteri Räty
2011-04-09 13:08 Petteri Räty
2011-04-09  6:36 Petteri Räty
2011-04-09  6:27 Petteri Räty
2011-04-09  6:27 Petteri Räty
2011-04-09  6:27 Petteri Räty
2011-04-09  6:27 Petteri Räty
2011-04-09  6:27 Petteri Räty
2011-04-08 14:26 Petteri Räty
2011-04-08 14:26 Petteri Räty
2011-04-07 16:44 Petteri Räty
2011-04-07  7:48 Petteri Räty
2011-04-06 15:07 Petteri Räty
2011-04-04 15:52 Petteri Räty
2011-04-02 15:50 Petteri Räty
2011-04-02 15:50 Petteri Räty
2011-03-22 20:52 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