aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMu Qiao <qiaomuf@gentoo.org>2011-07-29 20:54:12 +0800
committerMu Qiao <qiaomuf@gentoo.org>2011-08-02 15:52:19 +0800
commit1e51015b4e2e76a912e077faf772e6470090b130 (patch)
treeaa73c41c86c408c2e7673087ed3afeda3036dccc /bashast
parentParser: allow 'function' to be string literal (diff)
downloadlibbash-1e51015b4e2e76a912e077faf772e6470090b130.tar.gz
libbash-1e51015b4e2e76a912e077faf772e6470090b130.tar.bz2
libbash-1e51015b4e2e76a912e077faf772e6470090b130.zip
Parser: improve the rule for regular expression
Diffstat (limited to 'bashast')
-rw-r--r--bashast/bashast.g14
1 files changed, 11 insertions, 3 deletions
diff --git a/bashast/bashast.g b/bashast/bashast.g
index ea8185f..5549439 100644
--- a/bashast/bashast.g
+++ b/bashast/bashast.g
@@ -620,19 +620,27 @@ keyword_condition_binary
-> ^(MATCH_PATTERN condition_part ^(STRING extended_pattern_match+))
| -> condition_part
);
-//TODO improve this rule
bash_pattern_part
scope {
int parens;
+#ifdef OUTPUT_C
+ bool quoted;
+#else
+ boolean quoted;
+#endif
}
@init {
$bash_pattern_part::parens = 0;
+ $bash_pattern_part::quoted = false;
}
:(
- (ESC BLANK) => ESC BLANK
+ DQUOTE! { $bash_pattern_part::quoted = !$bash_pattern_part::quoted; }
+ | {$bash_pattern_part::quoted}? => ~DQUOTE
+ | (ESC BLANK) => ESC BLANK
| LPAREN { if(LA(-2) != ESC) $bash_pattern_part::parens++; }
+ | LLPAREN { if(LA(-2) != ESC) $bash_pattern_part::parens += 2; }
| {$bash_pattern_part::parens != 0}? => RPAREN { if(LA(-2) != ESC) $bash_pattern_part::parens--; }
- | ~(BLANK|EOL|LOGICAND|LOGICOR|LPAREN|RPAREN)
+ | ~(BLANK|EOL|LOGICAND|LOGICOR|LPAREN|RPAREN|DQUOTE|LLPAREN)
)+;
keyword_binary_string_operator
: BLANK! binary_operator BLANK!