Skip to content

Commit

Permalink
Update delete-useless-parentheses.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
kaby76 committed May 16, 2024
1 parent e28fbe8 commit e5ca411
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions delete-useless-parentheses.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,24 @@ cat $temp | $command '
(: Find all blocks... :)
//(block[
(: except not one of these ... :)
(: do not flag "a ( b | c )* d" or with other operator :)
not(./parent::ebnf/blockSuffix and ./altList/OR) and
(: do not flag "(a ( b | c )* )?" because it is not the same as the '*?'-operator. :)
not(./parent::ebnf/blockSuffix/ebnfSuffix/QUESTION and ./altList[count(./*) = 1]/alternative[count(./*) = 1]/element[count(./*) = 1]/ebnf[./block and ./blockSuffix/ebnfSuffix/*]) and
(: do not flag blocks that contain a lot of elements like "(a b c)*" :)
not(./parent::ebnf/blockSuffix and count(./altList/alternative/element) > 1) and
(: do not flag if there are alts *and* it is preceed or followed by an element,
e.g., "a (b | c d)" or "(a | b) c". :)
not(./altList/OR and ../../following-sibling::element) and
not(./altList/OR and ../../preceding-sibling::element) and
(: do not flag "a ( v += b )* c" or with other operator :)
not(./altList/alternative/element/labeledElement/(ASSIGN or PLUS_ASSIGN) and ./parent::ebnf/blockSuffix) and
not(./parent::labeledElement/(ASSIGN or PLUS_ASSIGN))
]
|
Expand Down

0 comments on commit e5ca411

Please sign in to comment.