-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d85fb7
commit 2853db1
Showing
4 changed files
with
54 additions
and
34 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
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package dregex; | ||
|
||
import dregex.impl.Compiler; | ||
import dregex.impl.Dfa; | ||
import dregex.impl.RegexTree; | ||
import dregex.impl.SimpleState; | ||
import lombok.NonNull; | ||
|
||
/** | ||
* A fully-compiled regular expression that was generated from a string literal. | ||
*/ | ||
public class CompiledRegex implements Regex { | ||
|
||
private final Universe _universe; | ||
private final String _originalString; | ||
private final RegexTree.Node _parsedTree; | ||
private final Dfa<SimpleState> _dfa; | ||
|
||
public CompiledRegex(@NonNull String originalString, @NonNull RegexTree.Node parsedTree, @NonNull Universe universe) { | ||
this._universe = universe; | ||
this._originalString = originalString; | ||
this._parsedTree = parsedTree; | ||
this._dfa = new Compiler(_universe.alphabet()).fromTree(_parsedTree); | ||
} | ||
|
||
@Override | ||
public Universe universe() { | ||
return _universe; | ||
} | ||
|
||
public String originalString() { | ||
return _originalString; | ||
} | ||
|
||
public RegexTree.Node parsedTree() { | ||
return _parsedTree; | ||
} | ||
|
||
@Override | ||
public Dfa<SimpleState> dfa() { | ||
return _dfa; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("⟪%s⟫ (DFA states: %s)", _originalString, _dfa.stateCount()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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