sealed abstract class Rx extends AnyRef
- Alphabetic
- By Inheritance
- Rx
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
&(rhs: Rx): Rx
Intersection operator.
-
def
*(rhs: Rx): Rx
Concatenation operator.
Concatenation operator.
The expression
x * y
means thatx
and theny
will be used in a given production in that order. In regular expression syntax this is written as 'xy'.The operator is called
*
because it corresponds to multiplication in the Kleene algebra of regular expressions. -
def
+(rhs: Rx): Rx
Choice operator.
Choice operator.
The expression
x + y
(also written asx | y
), means that eitherx
ory
(but not both) will be used in a given production. In regular expression syntax this is written as 'x|y'. This is also sometimes known as alternation.The operator is called
+
because it corresponds to addition in the Kleene algebra of regular expressions. -
def
-(rhs: Rx): Rx
Difference operator.
-
def
<(rhs: Rx): Boolean
Is lhs' accepted set a proper subset of rhs' accepted set?
-
def
<=(rhs: Rx): Boolean
Is lhs' accepted set a subset of rhs' accepted set?
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
===(rhs: Rx): Boolean
Do lhs and rhs accept the same set of strings?
-
def
>(rhs: Rx): Boolean
Is lhs' accepted set a proper superset of rhs' accepted set?
-
def
>=(rhs: Rx): Boolean
Is lhs' accepted set a superset of rhs' accepted set?
-
def
^(rhs: Rx): Rx
Exclusive-or (XOR) operator.
-
def
accepts(s: String): Boolean
Decide whether the regex accepts the string
s
. -
lazy val
acceptsEmpty: Boolean
Does this regular expression accept the empty string ("")?
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
canonical: Rx
Attempt to put a regular expression in a canonical form.
Attempt to put a regular expression in a canonical form.
This is not guaranteed to be a "minimal" form (in fact it will often expand the size of the regex). However, two regular exprssions that are equal should have equivalent representations after canonicalization is performed.
-
def
cardRepr: String
Represent the cardinality of this expression as a string.
Represent the cardinality of this expression as a string.
For finite cardinalities, just return that number.
For infinite star depths, we show ∞ and then display the first cardinalities where we limit star expansions.
-
def
cardinality: Size
Compute the size of the set of strings matched by this regular expression.
Compute the size of the set of strings matched by this regular expression.
In expressions using the Kleene star operator the cardinality will often be unbounded, since the set is infinite (at least in theory). To get a sense of the relative complexity of an expression using Kleene stars, consider exploring how the values of
limitStars(i).cardinality
increase asi
does.This method traverses the expression to avoid double-counting the same string which can be produced by two different paths
-
def
choices: Set[Rx]
Return a list of nodes to be chosen between.
Return a list of nodes to be chosen between.
If this node is a Choice node, the list will have two or more elements. Otherwise it will have exactly one element.
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
concats: List[Rx]
Return a list of nodes to be concatenated.
Return a list of nodes to be concatenated.
If this node is a Concat node, the list will have two or more elements. Otherwise it will have exactly one element.
-
def
deriv(c: Char): Rx
Compute the derivative with respect to
c
.Compute the derivative with respect to
c
.The derivative of a regular expressions with respect to
c
is a new regular expression that accepts a strings
if and only if the original expression acceptsc
+s
.For example, the derivative of '(abc)*' with respect to 'a' is '(bc)(abc)*'
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
lazy val
firstSet: List[LetterSet]
Set of "first characters" which this regex can accept.
Set of "first characters" which this regex can accept.
If a character is not in the firstSet, this regex cannot match strings starting with that character.
Each LetterSet represents one or more contiguous character ranges. We represent the first set as a list of LetterSets to ensure that each letter set is either completely valid, or completely invalid, for every internal Rx value. For this regex, we can treat each element of the list as a congruence class of characters (which are all treated the same by this regex and all its children). This is very important for efficiency.
For example, the first set for the expression ([a-c]|[b-d])e* would be List([a], [b-c], [d]). This is because [a] is only matched by [a-c], [d] is only matched by [b-d], and [b-c] is matched by both. If we instead returned something like List([a-c], [d]), then [b-d] would partially (but not completely) match [a-c].
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
isEmpty: Boolean
Is this regular expression equivalent to ε (empty)?
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isPhi: Boolean
Is this regular expressions equivalent to ϕ (phi)?
-
def
limitStars(count: Int): Rx
Limit applications of the Kleene star operator.
Limit applications of the Kleene star operator.
Replaces
Star(r)
nodes withRepeat(r, 0, count)
nodes. This has the effect of limiting any Kleene star in the expression to being expanded at mostcount
times. -
lazy val
matchSizes: Option[(Size, Size)]
Return the range of string lenghts (if any) matched by this regular expression.
Return the range of string lenghts (if any) matched by this regular expression.
ϕ (or regular expressions equivalent to ϕ) will return None. All other expressions will return Some((x, y)), where 0 <= x <= y < ∞.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
optional: Rx
Optionality operator.
Optionality operator.
The expression
x.optional
means thatx
will be applied zero-or-one times. In regular expression syntax this would be written as 'x?'. -
def
partialCompare(rhs: Rx): Double
Partial comparison using a subset relation between regular expressions.
Partial comparison using a subset relation between regular expressions.
The return value represents the relationship:
<0 means (lhs < rhs) means lhs is a subset of rhs 0 means (lhs = rhs) means lhs is equivalent to rhs >0 means (lhs > rhs) means lhs is a supserset of rhs NaN means none of the above
-
def
partialDeriv(x: Char): Set[Rx]
Compute the partial derivatives with respect to
x
.Compute the partial derivatives with respect to
x
.A partial derivative of a regular expression with respect to
x
is a new regular expression that only accepts a strings
if the original expression acceptsx
+s
.Unlike a derivative, if a partial derivative does not match
s
that does not mean that the original regular expression would not matchx
+s
-- there may be some other partial derivative that does matchs
.If you calculate all the partial derivatives and union them together, you get a regular expression that is equivalent to the derivative. (In fact, this is how Antimirov implements the derivative operation.)
We use a Set here to avoid duplicate partial derivatives.
-
def
plus: Rx
Kleene plus operator.
Kleene plus operator.
The expression
x.plus
means thatx
will be applied one-or-more times. In regular expression syntax this would be written as 'x+'.Kleene plus is implemented in terms of Kleene star:
x.plus = x * x.star
Kleene plus also satisfies the self-referential relation:
x.plus = x * (Empty + x.plus)
-
def
pow(k: Int): Rx
Exponentiation operator.
Exponentiation operator.
x.pow(k)
is equivalent tox * x *... * x
k times. This can be written in regular expression syntax asx{k}
.x.pow(k)
is equivalent tox.repeat(k, k)
in the same way that 'x{k}' is equivalent to 'x{k,k}' in regular expression syntax. -
def
properSubsetOf(rhs: Rx): Boolean
Is lhs a proper subset of rhs?
-
def
properSupersetOf(rhs: Rx): Boolean
Is lhs a proper superset of rhs?
-
def
reRepr: String
Represent this value using traditional "regex" syntax.
Represent this value using traditional "regex" syntax.
The output of this method should be readable by Rx.parse.
-
def
rejects(s: String): Boolean
Decide whether the regex rejects the string
s
. -
def
rejectsEmpty: Boolean
Does this regular expression reject the empty string ("")?
-
def
repeat(m: Int, n: Int): Rx
Repetition operator.
Repetition operator.
This repeats the given regex for at least
m
times and no more thann
times (so 0 <= m <= n). If n=0 this is equivalent to the empty string.This method is equivalent to m concatenations followed by (n - m) choice operations and concatenations, e.g.
x{3,5} = xxx(|x(|x))
-
def
reverse: Rx
Reverse the regular expression.
Reverse the regular expression.
For every string matched by the original expression, the reversed expression matches the reversed string. There are no other differences, and .reverse.reverse is a no-op.
-
def
scalaRepr: String
Represent this value using Scala syntax.
Represent this value using Scala syntax.
The output of this method should be usable in the REPL.
-
def
star: Rx
Kleene star operator.
Kleene star operator.
The expression
x.star
means thatx
will be applied zero-or-more times. In regular expression syntax this would be written as 'x*'.Kleene star satisfies the self-referential relation:
x.star = Empty + (x * x.star)
-
def
starDepth: Int
The deepest number of nested Kleene star operators in this expression.
The deepest number of nested Kleene star operators in this expression.
This can be used as a complexity measure.
-
def
subsetOf(rhs: Rx): Boolean
Is lhs a subset of rhs?
-
def
supersetOf(rhs: Rx): Boolean
Is lhs a superset of rhs?
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
- def toDfa: Dfa
-
def
toJava: Pattern
Compile this regular expression to a java.util.regex.Pattern.
- def toNfa: Nfa
-
def
toScala: Regex
Compile this regular expression to a scala.util.matching.Regex.
-
def
toString(): String
String representation of Rx.
String representation of Rx.
- Definition Classes
- Rx → AnyRef → Any
-
def
unary_~: Rx
Complement (negation) operator.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
|(rhs: Rx): Rx
Alias for the choice operator.