-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from sgreben/fix-complement
Fix complement, support pattern flags
- Loading branch information
Showing
45 changed files
with
553 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ | |
/settings.xml | ||
/gpg-params | ||
/gpg-home | ||
/.project | ||
/.classpath | ||
/.settings | ||
/.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
src/main/java/com/github/sgreben/regex_builder/charclass/AnyCharacter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
package com.github.sgreben.regex_builder.charclass; | ||
|
||
import com.github.sgreben.regex_builder.CharClass; | ||
import com.github.sgreben.regex_builder.tokens.DOT; | ||
import com.github.sgreben.regex_builder.tokens.TOKEN; | ||
|
||
public class AnyCharacter extends Nullary { | ||
@Override | ||
public CharClass complement() { | ||
return oneOf(""); | ||
} | ||
|
||
@Override | ||
public void compile(java.util.List<TOKEN> output) { | ||
output.add(new DOT()); | ||
} | ||
} | ||
} |
13 changes: 11 additions & 2 deletions
13
src/main/java/com/github/sgreben/regex_builder/charclass/BeginInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
package com.github.sgreben.regex_builder.charclass; | ||
|
||
import com.github.sgreben.regex_builder.CharClass; | ||
import com.github.sgreben.regex_builder.tokens.RAW; | ||
import com.github.sgreben.regex_builder.tokens.TOKEN; | ||
|
||
public class BeginInput extends Nullary { | ||
public BeginInput() {} | ||
public BeginInput() { | ||
} | ||
|
||
@Override | ||
public CharClass complement() { | ||
return new RawComplement(this); | ||
} | ||
|
||
@Override | ||
public void compile(java.util.List<TOKEN> output) { | ||
output.add(new RAW("\\A")); | ||
} | ||
} | ||
} |
15 changes: 7 additions & 8 deletions
15
src/main/java/com/github/sgreben/regex_builder/charclass/Binary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
package com.github.sgreben.regex_builder.charclass; | ||
|
||
import com.github.sgreben.regex_builder.CharClass; | ||
|
||
import java.util.List; | ||
import java.util.LinkedList; | ||
import java.lang.Iterable; | ||
import java.util.Collections; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
import com.github.sgreben.regex_builder.CharClass; | ||
|
||
abstract class Binary extends CharClassBase { | ||
private final List<CharClass> children; | ||
|
||
public Binary(CharClass leftChild, CharClass rightChild) { | ||
List<CharClass> children = new LinkedList<CharClass>(); | ||
children.add(leftChild); | ||
children.add(rightChild); | ||
this.children = Collections.unmodifiableList(children); | ||
} | ||
|
||
|
||
@Override | ||
public Iterable<CharClass> children() { | ||
return children; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 16 additions & 12 deletions
28
src/main/java/com/github/sgreben/regex_builder/charclass/Complement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
package com.github.sgreben.regex_builder.charclass; | ||
|
||
import com.github.sgreben.regex_builder.tokens.CARET; | ||
import com.github.sgreben.regex_builder.tokens.END_CHAR_CLASS; | ||
import com.github.sgreben.regex_builder.tokens.START_CHAR_CLASS; | ||
import com.github.sgreben.regex_builder.tokens.TOKEN; | ||
import com.github.sgreben.regex_builder.CharClass; | ||
import com.github.sgreben.regex_builder.tokens.TOKEN; | ||
|
||
public class Complement extends Unary { | ||
public Complement(CharClass child) { super(child); } | ||
public void compile(java.util.List<TOKEN> output) { | ||
output.add(new START_CHAR_CLASS()); | ||
output.add(new CARET()); | ||
for(CharClass child : children()) { | ||
child.compile(output); | ||
} | ||
output.add(new END_CHAR_CLASS()); | ||
final CharClass child; | ||
|
||
public Complement(final CharClass child) { | ||
super(child); | ||
this.child = child; | ||
} | ||
|
||
@Override | ||
public CharClass complement() { | ||
return child; | ||
} | ||
|
||
@Override | ||
public void compile(final java.util.List<TOKEN> output) { | ||
child.complement().compile(output); | ||
} | ||
} |
13 changes: 11 additions & 2 deletions
13
src/main/java/com/github/sgreben/regex_builder/charclass/Digit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
package com.github.sgreben.regex_builder.charclass; | ||
|
||
import com.github.sgreben.regex_builder.CharClass; | ||
import com.github.sgreben.regex_builder.tokens.RAW; | ||
import com.github.sgreben.regex_builder.tokens.TOKEN; | ||
|
||
public class Digit extends Nullary { | ||
public Digit() {} | ||
public Digit() { | ||
} | ||
|
||
@Override | ||
public CharClass complement() { | ||
return new NonDigit(); | ||
} | ||
|
||
@Override | ||
public void compile(java.util.List<TOKEN> output) { | ||
output.add(new RAW("\\d")); | ||
} | ||
} | ||
} |
13 changes: 11 additions & 2 deletions
13
src/main/java/com/github/sgreben/regex_builder/charclass/EndInput.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
package com.github.sgreben.regex_builder.charclass; | ||
|
||
import com.github.sgreben.regex_builder.CharClass; | ||
import com.github.sgreben.regex_builder.tokens.RAW; | ||
import com.github.sgreben.regex_builder.tokens.TOKEN; | ||
|
||
public class EndInput extends Nullary { | ||
public EndInput() {} | ||
public EndInput() { | ||
} | ||
|
||
@Override | ||
public CharClass complement() { | ||
return new RawComplement(this); | ||
} | ||
|
||
@Override | ||
public void compile(java.util.List<TOKEN> output) { | ||
output.add(new RAW("\\z")); | ||
} | ||
} | ||
} |
13 changes: 11 additions & 2 deletions
13
src/main/java/com/github/sgreben/regex_builder/charclass/EndInputBeforeFinalTerminator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
package com.github.sgreben.regex_builder.charclass; | ||
|
||
import com.github.sgreben.regex_builder.CharClass; | ||
import com.github.sgreben.regex_builder.tokens.RAW; | ||
import com.github.sgreben.regex_builder.tokens.TOKEN; | ||
|
||
public class EndInputBeforeFinalTerminator extends Nullary { | ||
public EndInputBeforeFinalTerminator() {} | ||
public EndInputBeforeFinalTerminator() { | ||
} | ||
|
||
@Override | ||
public CharClass complement() { | ||
return new RawComplement(this); | ||
} | ||
|
||
@Override | ||
public void compile(java.util.List<TOKEN> output) { | ||
output.add(new RAW("\\z")); | ||
} | ||
} | ||
} |
Oops, something went wrong.