Skip to content

Commit e5ca411

Browse files
committed
Update delete-useless-parentheses.sh
1 parent e28fbe8 commit e5ca411

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: delete-useless-parentheses.sh

+14
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,24 @@ cat $temp | $command '
6868
(: Find all blocks... :)
6969
//(block[
7070
(: except not one of these ... :)
71+
72+
(: do not flag "a ( b | c )* d" or with other operator :)
7173
not(./parent::ebnf/blockSuffix and ./altList/OR) and
74+
75+
(: do not flag "(a ( b | c )* )?" because it is not the same as the '*?'-operator. :)
76+
not(./parent::ebnf/blockSuffix/ebnfSuffix/QUESTION and ./altList[count(./*) = 1]/alternative[count(./*) = 1]/element[count(./*) = 1]/ebnf[./block and ./blockSuffix/ebnfSuffix/*]) and
77+
78+
(: do not flag blocks that contain a lot of elements like "(a b c)*" :)
7279
not(./parent::ebnf/blockSuffix and count(./altList/alternative/element) > 1) and
80+
81+
(: do not flag if there are alts *and* it is preceed or followed by an element,
82+
e.g., "a (b | c d)" or "(a | b) c". :)
7383
not(./altList/OR and ../../following-sibling::element) and
7484
not(./altList/OR and ../../preceding-sibling::element) and
85+
86+
(: do not flag "a ( v += b )* c" or with other operator :)
87+
not(./altList/alternative/element/labeledElement/(ASSIGN or PLUS_ASSIGN) and ./parent::ebnf/blockSuffix) and
88+
7589
not(./parent::labeledElement/(ASSIGN or PLUS_ASSIGN))
7690
]
7791
|

0 commit comments

Comments
 (0)