public abstract class TRegular extends Object
TRegular
represent tagged
regular expressions.
Tagged regular expressions are an intermediate form of compiled regular expressions where bindings have been replaced by pair of "tags" enclosing the bound parts of regular expressions, and where character sets are replaced by indices in an external map of character sets. When a bounded expression is guaranteed to match only single characters, it is marked by a single starting tag and has no closing tag.
In a latter phase, they can also reference semantic actions to be executed at the point where they are encountered when matching the expression.
They are immutable objects, and have therefore value semantics.
Modifier and Type | Class and Description |
---|---|
static class |
TRegular.Action
Stands for a semantic action to be executed
when matching reaches this regular expression.
|
static class |
TRegular.Alternate
Instances of tagged regular expressions that represent a
choice
a | b between two regular expressions. |
static class |
TRegular.Characters
Instances of regular expressions that match exactly
one character amongst a set of possible characters.
|
static class |
TRegular.Epsilon
The singleton class that stands for the empty tagged
regular expression ε, which only matches the empty string.
|
static class |
TRegular.Kind
Enumeration which describes the different kinds of
concrete implementations of
TRegular . |
static class |
TRegular.Repetition
Instances of tagged regular expressions that represent the
Kleene closure
r* of some regular expression r ,
i.e. matching zero, one or more repetitions of r |
static class |
TRegular.Sequence
Instances of tagged regular expressions that represent the
concatenation
ab of two regular expressions. |
static class |
TRegular.Tag
Instances of tagged regular expressions that represent
a tag, i.e. either the beginning or the end of some
bound sub-expression
|
static class |
TRegular.TagInfo
Describes a tag, i.e. a marker
used in tagged regular expressions
to represent the boundaries of bound sub-expressions
|
Modifier and Type | Field and Description |
---|---|
static TRegular.Epsilon |
EPSILON
The empty tagged regular expression ε
|
boolean |
hasActions
Whether this regular expressions has any
semantic actions or not
|
boolean |
hasTags
Whether this regular expressions has any
tags or not
|
TRegular.Kind |
kind
Specifies what kind of regular expression
this is |
boolean |
nullable
Whether this tagged regular expression matches the empty string.
|
int |
size
If
size >= 0, all strings matching this
regular expression have the specified size. |
Modifier and Type | Method and Description |
---|---|
static TRegular.Action |
action(int action) |
static TRegular |
chars(int cset,
boolean eof)
If
eof is true, cset must point to a
singleton end-of-input. |
TRegular.Kind |
getKind()
Only there for the quick-assist based on
Hierarchy . |
static TRegular |
or(TRegular lhs,
TRegular rhs) |
static TRegular |
seq(TRegular first,
TRegular second) |
static TRegular |
star(TRegular reg) |
static TRegular.Tag |
tag(String id,
boolean start,
int action) |
abstract @NonNull String |
toString() |
public final TRegular.Kind kind
this
ispublic final int size
size
>= 0, all strings matching this
regular expression have the specified size.
If size
is negative, then no size is
guaranteed.public final boolean hasTags
public final boolean hasActions
public final boolean nullable
Note that the end-of-file regular expression does not match the empty string, it matches a special character set instead.
public static final TRegular.Epsilon EPSILON
public final TRegular.Kind getKind()
Hierarchy
.
You should probably use the field kind
directly.kind
public static TRegular chars(int cset, boolean eof)
eof
is true, cset
must point to a
singleton end-of-input. Otherwise, cset
must not
contain the end-of-input marker.cset
- eof
- chars
public static TRegular.Tag tag(String id, boolean start, int action)
id
- start
- action
- TRegular.TagInfo
public static TRegular or(TRegular lhs, TRegular rhs)
lhs
- rhs
- lhs
and rhs
,
in this orderpublic static TRegular seq(TRegular first, TRegular second)
first
- second
- first
and second
,
in this orderpublic static TRegular star(TRegular reg)
reg
- reg
public static TRegular.Action action(int action)
action
-