Skip to content

Commit d4f5232

Browse files
committed
Remove redundant handling of empty in simpleRE parser.
1 parent e325572 commit d4f5232

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

core/src/main/java/com/github/simy4/coregex/core/CoregexParser.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,13 @@ private Coregex RE(Context ctx) {
8888
* }</pre>
8989
*/
9090
private Coregex simpleRE(Context ctx) {
91-
Coregex simpleRE = Coregex.empty();
91+
Coregex simpleRE = basicRE(ctx);
9292
if (ctx.hasMoreElements() && '|' != ctx.peek() && ')' != ctx.peek()) {
93-
simpleRE = basicRE(ctx);
94-
if (ctx.hasMoreElements() && '|' != ctx.peek() && ')' != ctx.peek()) {
95-
List<Coregex> concatenation = new ArrayList<>();
96-
while (ctx.hasMoreElements() && '|' != ctx.peek() && ')' != ctx.peek()) {
97-
concatenation.add(basicRE(ctx));
98-
}
99-
simpleRE = new Coregex.Concat(simpleRE, concatenation.toArray(new Coregex[0]));
93+
List<Coregex> concatenation = new ArrayList<>();
94+
while (ctx.hasMoreElements() && '|' != ctx.peek() && ')' != ctx.peek()) {
95+
concatenation.add(basicRE(ctx));
10096
}
97+
simpleRE = new Coregex.Concat(simpleRE, concatenation.toArray(new Coregex[0]));
10198
}
10299
return simpleRE;
103100
}

0 commit comments

Comments
 (0)