You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: find-useless-parentheses.sh
+9-5Lines changed: 9 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -36,18 +36,22 @@ compute() {
36
36
//block[
37
37
(: except not one of these ... :)
38
38
39
-
(: do not flag "a ( b | c )* d" or with other operator :)
39
+
(: do not flag "a ( b | c )* d" or with other operator :)
40
40
not(./parent::ebnf/blockSuffix and ./altList/OR) and
41
41
42
-
(: do not flag "(a ( b | c )* )?" because it is not the same as the '*?'-operator. :)
42
+
(: do not flag "(a ( b | c )* )?" because it is not the same as the '*?'-operator. :)
43
43
not(./parent::ebnf/blockSuffix/ebnfSuffix/QUESTION and ./altList[count(./*) = 1]/alternative[count(./*) = 1]/element[count(./*) = 1]/ebnf[./block and ./blockSuffix/ebnfSuffix/*]) and
44
44
45
+
(: do not flag blocks that contain a lot of elements like "(a b c)*" :)
45
46
not(./parent::ebnf/blockSuffix and count(./altList/alternative/element) > 1) and
47
+
48
+
(: do not flag if there are alts *and* it is preceed or followed by an element,
49
+
e.g., "a (b | c d)" or "(a | b) c". :)
46
50
not(./altList/OR and ../../following-sibling::element) and
47
51
not(./altList/OR and ../../preceding-sibling::element) and
48
52
49
-
(: do not flag "a ( v += b )* c" or with other operator :)
50
-
not(./altList/alternative/element/labeledElement/(ASSIGN or PLUS_ASSIGN) and ./parent::ebnf/blockSuffix) and
53
+
(: do not flag "a ( v += b )* c" or with other operator :)
54
+
not(./altList/alternative/element/labeledElement/(ASSIGN or PLUS_ASSIGN) and ./parent::ebnf/blockSuffix) and
51
55
52
56
not(./parent::labeledElement/(ASSIGN or PLUS_ASSIGN))
53
57
]'| trcaret -- -H > up-output.txt
@@ -72,7 +76,7 @@ compute() {
72
76
if [ -s up-output.txt ]
73
77
then
74
78
echo Found useless parentheses in grammars... 1>&2
0 commit comments