/// <summary> /// Create a new incremental symbolic regex builder. /// </summary> /// <param name="solver">Effective Boolean algebra over S.</param> public SymbolicRegexBuilder(ICharAlgebra <S> solver) { this.solver = solver; this.epsilon = SymbolicRegex <S> .MkEpsilon(this); this.nothing = SymbolicRegex <S> .MkFalse(this); singletonCache[solver.False] = this.nothing; this.dot = SymbolicRegex <S> .MkTrue(this); singletonCache[solver.True] = this.dot; this.dotStar = SymbolicRegex <S> .MkDotStar(this, this.dot); this.startAnchor = SymbolicRegex <S> .MkStartAnchor(this); this.endAnchor = SymbolicRegex <S> .MkEndAnchor(this); this.eolAnchor = SymbolicRegex <S> .MkEolAnchor(this); this.bolAnchor = SymbolicRegex <S> .MkBolAnchor(this); this.newLine = SymbolicRegex <S> .MkNewline(this); singletonCache[this.newLine.set] = this.newLine; this.bolRegex = SymbolicRegex <S> .MkLoop(this, SymbolicRegex <S> .MkConcat(this, this.dotStar, this.newLine), 0, 1); this.eolRegex = SymbolicRegex <S> .MkLoop(this, SymbolicRegex <S> .MkConcat(this, this.newLine, this.dotStar), 0, 1); }
/// <summary> /// Make loop regex /// </summary> public SymbolicRegex <S> MkLoop(SymbolicRegex <S> regex, int lower = 0, int upper = int.MaxValue) { if (lower == 1 && upper == 1) { return(regex); } else if (lower == 0 && upper == 0) { return(this.epsilon); } else if (lower == 0 && upper == int.MaxValue && regex.kind == SymbolicRegexKind.Singleton && this.solver.AreEquivalent(this.solver.True, regex.set)) { return(this.dotStar); } else { return(SymbolicRegex <S> .MkLoop(this, regex, lower, upper)); } }