Skip to content

Commit 5d94da1

Browse files
committed
Fix #3
1 parent 998ac7b commit 5d94da1

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

find-useless-parentheses.sh

+23-10
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,44 @@ main() {
3131

3232
compute() {
3333
found=0
34-
cat o.pt | trxgrep -- '
34+
cat o.pt | trquery -- grep '
3535
(: Find all blocks... :)
3636
//block[
3737
(: except not one of these ... :)
3838
3939
(: do not flag "a ( b | c )* d" or with other operator :)
40-
not(./parent::ebnf/blockSuffix and ./altList/OR) and
40+
not(./parent::ebnf/blockSuffix and ./altList/OR)
4141
4242
(: do not flag "(a ( b | c )* )?" because it is not the same as the '*?'-operator. :)
43-
not(./parent::ebnf/blockSuffix/ebnfSuffix/QUESTION and ./altList[count(./*) = 1]/alternative[count(./*) = 1]/element[count(./*) = 1]/ebnf[./block and ./blockSuffix/ebnfSuffix/*]) and
43+
and not(./parent::ebnf/blockSuffix/ebnfSuffix/QUESTION and ./altList[count(./*) = 1]/alternative[count(./*) = 1]/element[count(./*) = 1]/ebnf[./block and ./blockSuffix/ebnfSuffix/*])
4444
4545
(: do not flag blocks that contain a lot of elements like "(a b c)*" :)
46-
not(./parent::ebnf/blockSuffix and count(./altList/alternative/element) > 1) and
46+
and not(./parent::ebnf/blockSuffix and count(./altList/alternative/element) > 1)
4747
4848
(: do not flag if there are alts *and* it is preceed or followed by an element,
4949
e.g., "a (b | c d)" or "(a | b) c". :)
50-
not(./altList/OR and ../../following-sibling::element) and
51-
not(./altList/OR and ../../preceding-sibling::element) and
50+
and not(./altList/OR and ../../following-sibling::element)
51+
and not(./altList/OR and ../../preceding-sibling::element)
5252
5353
(: 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
54+
and not(
55+
(
56+
(count(./altList/alternative/element/labeledElement/ASSIGN) > 0)
57+
or
58+
(count(./altList/alternative/element/labeledElement/PLUS_ASSIGN) > 0)
59+
)
60+
and (count(./parent::ebnf/blockSuffix) > 0)
61+
)
5562
56-
not(./parent::labeledElement/(ASSIGN or PLUS_ASSIGN))
63+
and not(
64+
(
65+
(count(./parent::labeledElement/ASSIGN) > 0)
66+
or
67+
(count(./parent::labeledElement/PLUS_ASSIGN) > 0)
68+
)
69+
)
5770
]' | trcaret -- -H > up-output.txt
58-
cat o.pt | trxgrep -- '
71+
cat o.pt | trquery -- grep '
5972
(: Find all blocks... :)
6073
//lexerBlock[
6174
(: except not one of these ... :)
@@ -67,7 +80,7 @@ compute() {
6780
not(count(./lexerAltList/lexerAlt) > 1 and ../../../lexerCommands) and
6881
not(./parent::labeledLexerElement/(ASSIGN or PLUS_ASSIGN))
6982
]' | trcaret -- -H >> up-output.txt
70-
cat o.pt | trxgrep -- '
83+
cat o.pt | trquery -- grep '
7184
(: Find all blockSets... :)
7285
//blockSet[
7386
(: except not one of these ... :)

0 commit comments

Comments
 (0)