From e5ca411ddbf8eb9fb97e986c99d124991e839899 Mon Sep 17 00:00:00 2001 From: Ken Domino Date: Thu, 16 May 2024 18:17:31 -0400 Subject: [PATCH] Update delete-useless-parentheses.sh --- delete-useless-parentheses.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/delete-useless-parentheses.sh b/delete-useless-parentheses.sh index 3540929..06d2350 100644 --- a/delete-useless-parentheses.sh +++ b/delete-useless-parentheses.sh @@ -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)) ] |