Skip to content

Commit 7fa99fd

Browse files
committed
Fix RangeComplement
1 parent 6970d81 commit 7fa99fd

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/main/java/com/github/sgreben/regex_builder/charclass/RangeComplement.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
package com.github.sgreben.regex_builder.charclass;
22

33
import com.github.sgreben.regex_builder.CharClass;
4-
import com.github.sgreben.regex_builder.tokens.*;
4+
import com.github.sgreben.regex_builder.tokens.CARET;
5+
import com.github.sgreben.regex_builder.tokens.DASH;
6+
import com.github.sgreben.regex_builder.tokens.END_CHAR_CLASS;
7+
import com.github.sgreben.regex_builder.tokens.RAW;
8+
import com.github.sgreben.regex_builder.tokens.START_CHAR_CLASS;
9+
import com.github.sgreben.regex_builder.tokens.TOKEN;
510

611
public class RangeComplement extends Nullary {
712
private final char[] range;
13+
814
public RangeComplement(char... range) {
915
this.range = range;
1016
}
1117

1218
@Override
13-
public CharClass complement() { return new RawComplement(this); }
19+
public CharClass complement() {
20+
return new Range(range);
21+
}
1422

1523
@Override
1624
public void compile(java.util.List<TOKEN> output) {
1725
output.add(new START_CHAR_CLASS());
1826
output.add(new CARET());
19-
for(int i = 0; i < range.length; i += 2) {
20-
output.add(new RAW(""+range[i]));
27+
for (int i = 0; i < range.length; i += 2) {
28+
output.add(new RAW("" + range[i]));
2129
output.add(new DASH());
22-
output.add(new RAW(""+range[i+1]));
30+
output.add(new RAW("" + range[i + 1]));
2331

2432
}
2533
output.add(new END_CHAR_CLASS());

0 commit comments

Comments
 (0)