diff --git a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/string/tarsis/RegexAutomaton.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/string/tarsis/RegexAutomaton.java index b07061f0d..fafe115a8 100644 --- a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/string/tarsis/RegexAutomaton.java +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/string/tarsis/RegexAutomaton.java @@ -471,14 +471,35 @@ public RegexAutomaton repeat(long n) { return toRegex().simplify().repeat(n).toAutomaton(this).minimize(); } + /** + * Yields a new automaton where leading whitespaces have been removed from + * {@code this}. + * + * @return a new automaton where leading whitespaces have been removed from + * {@code this} + */ public RegexAutomaton trimLeft() { return this.toRegex().trimLeft().simplify().toAutomaton(this); } + /** + * Yields a new automaton where trailing whitespaces have been removed from + * {@code this}. + * + * @return a new automaton where trailing whitespaces have been removed from + * {@code this} + */ public RegexAutomaton trimRight() { return this.toRegex().trimRight().simplify().toAutomaton(this); } + /** + * Yields a new automaton where trailing and leading whitespaces have been + * removed from {@code this}. + * + * @return a new automaton where trailing and leading whitespaces have been + * removed from {@code this} + */ public RegexAutomaton trim() { return this.toRegex().trimRight().simplify().trimLeft().simplify().toAutomaton(this); } diff --git a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/string/tarsis/Tarsis.java b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/string/tarsis/Tarsis.java index ec17bf0b7..710edb96d 100644 --- a/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/string/tarsis/Tarsis.java +++ b/lisa/lisa-analyses/src/main/java/it/unive/lisa/analysis/string/tarsis/Tarsis.java @@ -407,6 +407,18 @@ public Satisfiability containsChar(char c) throws SemanticException { new Tarsis(RegexAutomaton.string(String.valueOf(c))), null); } + /** + * Yields a new Tarsis's instance recognizing each string of {@code this} + * automaton repeated k-times, with k belonging to {@code intv}. + * + * @param intv the interval + * + * @return a new Tarsis's instance recognizing each string of {@code this} + * automaton repeated k-times, with k belonging to {@code intv} + * + * @throws MathNumberConversionException if {@code intv} is iterated but is + * not finite + */ public Tarsis repeat(Interval intv) throws MathNumberConversionException { if (intv.isTop() || a.hasCycle()) return new Tarsis(a.star()); @@ -424,6 +436,13 @@ else if (intv.interval.isFinite()) { return new Tarsis(a.repeat(intv.interval.getLow().toLong()).concat(a.star())); } + /** + * Yields a new Tarsis's instance where trailing and leading whitespaces + * have been removed from {@code this}. + * + * @return a new Tarsis's instance where trailing and leading whitespaces + * have been removed from {@code this} + */ public Tarsis trim() { return new Tarsis(this.a.trim()); } diff --git a/lisa/lisa-sdk/src/main/java/it/unive/lisa/util/datastructures/regex/RegularExpression.java b/lisa/lisa-sdk/src/main/java/it/unive/lisa/util/datastructures/regex/RegularExpression.java index cd4344a9f..a876aef12 100644 --- a/lisa/lisa-sdk/src/main/java/it/unive/lisa/util/datastructures/regex/RegularExpression.java +++ b/lisa/lisa-sdk/src/main/java/it/unive/lisa/util/datastructures/regex/RegularExpression.java @@ -310,10 +310,33 @@ public String toString() { */ protected abstract Set substringAux(int charsToSkip, int missingChars); + /** + * Yields a new regular expression corresponding to the {@code n}-repetition + * of {@code this}. + * + * @param n number of repetitions + * + * @return a new regular expression corresponding to the + * {@code n}-repetition of {@code this} + */ public abstract RegularExpression repeat(long n); + /** + * Yields a new regular expression where leading whitespaces have been + * removed from {@code this}. + * + * @return a new regular expression where leading whitespaces have been + * removed from {@code this} + */ public abstract RegularExpression trimLeft(); + /** + * Yields a new regular expression where trailing whitespaces have been + * removed from {@code this}. + * + * @return a new regular expression where trailing whitespaces have been + * removed from {@code this} + */ public abstract RegularExpression trimRight(); /**