|
jInfer | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cz.cuni.mff.ksi.jinfer.base.regexp.Regexp<T>
T
- public class Regexp<T>
Class representing a regular expression of arbitrary type.
RegexpInterval
associated with it.
Constructor Summary | |
---|---|
Regexp(T content,
List<Regexp<T>> children,
RegexpType type,
RegexpInterval interval)
Creates immutable regexp. |
Method Summary | ||
---|---|---|
void |
addChild(Regexp<T> child)
Shorthand for getChildren().add(). |
|
void |
branch(int position)
Converts the i-th position of this concatenation to alternation and inserts the rest as the one and only of its children. |
|
static
|
getAlternation(List<Regexp<T>> children)
Get immutable alternation regexp with interval set to {1, 1}. |
|
static
|
getAlternation(List<Regexp<T>> children,
RegexpInterval interval)
Get immutable alternation regexp. |
|
Regexp<T> |
getChild(int i)
Shorthand for getChildren().get(). |
|
List<Regexp<T>> |
getChildren()
|
|
static
|
getConcatenation(List<Regexp<T>> children)
Get immutable concatenation regexp with interval set to {1, 1}. |
|
static
|
getConcatenation(List<Regexp<T>> children,
RegexpInterval interval)
Get immutable concatenation regexp. |
|
T |
getContent()
|
|
Regexp<T> |
getEnd(int from)
Returns a new concatenation containing the suffix of the specified concatenation, that is children from index specified by parameter from up to the end. |
|
RegexpInterval |
getInterval()
|
|
static
|
getLambda()
Get immutable lambda regexp. |
|
static
|
getMutable()
Get empty (members not set) regexp which is mutable. |
|
static
|
getPermutation(List<Regexp<T>> children)
Get immutable permutation regexp with interval set to {1, 1}. |
|
static
|
getPermutation(List<Regexp<T>> children,
RegexpInterval interval)
Get immutable permutation regexp. |
|
static
|
getToken(T content)
Get immutable token regexp with interval set to {1, 1}. |
|
static
|
getToken(T content,
RegexpInterval interval)
Get immutable token regexp. |
|
List<T> |
getTokens()
Returns all tokens contained in this regular expression, inorder from the left to the right. |
|
RegexpType |
getType()
|
|
boolean |
isAlternation()
If it is alternation. |
|
boolean |
isConcatenation()
If it is concatenation type. |
|
boolean |
isLambda()
If it is lambda. |
|
boolean |
isPermutation()
If it is permutation. |
|
boolean |
isToken()
If it is token type. |
|
void |
setContent(T content)
Set content of the regexp if it is mutable. |
|
void |
setImmutable()
Lock the regexp to be immutable from now. |
|
void |
setInterval(RegexpInterval interval)
Set interval of regexp when it is mutable, throws exception when regexp is immutable. |
|
void |
setType(RegexpType type)
Set type of regexp when it is mutable, throws exception when regexp is immutable. |
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Regexp(T content, List<Regexp<T>> children, RegexpType type, RegexpInterval interval)
content
- content of token regexp or null for not-tokenschildren
- children of concatenations, alternation and permutation regexpstype
- type of regexpinterval
- interval of regexpMethod Detail |
---|
public static <T> Regexp<T> getMutable()
Regexp r = Regexp.getMutable();
r.setType(RegexpType.LAMBDA);
r.setImmutable();cz.cuni.mff.ksi.jinfer.base
or
Regexp r = Regexp.getMutable();
r.setInterval(...);
r.setType(RegexpType.TOKEN);
r.setContent(...)
r.setImmutable();
or
Regexp r = Regexp.getMutable();
r.setInterval(...);
r.setType(RegexpType.CONCATENATION);
r.addChild(...);
r.addChild(...);
r.addChild(...);
r.setImmutable();
Take care to setup all members correctly and lock regexp.
T
-
public static <T> Regexp<T> getLambda()
T
-
public static <T> Regexp<T> getToken(T content, RegexpInterval interval)
T
- content
- symbol of regexpinterval
- associated interval, e.g. {3,7}
public static <T> Regexp<T> getToken(T content)
T
- content
- symbol of regexp
public static <T> Regexp<T> getConcatenation(List<Regexp<T>> children, RegexpInterval interval)
T
- children
- of this regexp, that are subregexps.interval
- associated interval, e.g. {3,7}
public static <T> Regexp<T> getConcatenation(List<Regexp<T>> children)
T
- children
- of this regexp, that are subregexps.
public static <T> Regexp<T> getAlternation(List<Regexp<T>> children, RegexpInterval interval)
T
- children
- of this regexp, that are subregexps.interval
- associated interval, e.g. {3,7}
public static <T> Regexp<T> getAlternation(List<Regexp<T>> children)
T
- children
- of this regexp, that are subregexps.
public static <T> Regexp<T> getPermutation(List<Regexp<T>> children, RegexpInterval interval)
T
- children
- of this regexp, that are subregexps.interval
- associated interval, e.g. {3,7}
public static <T> Regexp<T> getPermutation(List<Regexp<T>> children)
T
- children
- of this regexp, that are subregexps.
public void setContent(T content)
content
- public T getContent()
public List<Regexp<T>> getChildren()
public void setType(RegexpType type)
type
- desired typepublic RegexpType getType()
public void setInterval(RegexpInterval interval)
interval
- desired intervalpublic RegexpInterval getInterval()
public void setImmutable()
public Regexp<T> getChild(int i)
i
- Which child to fetch.
public void addChild(Regexp<T> child)
child
- Which child to add.public List<T> getTokens()
public boolean isToken()
public boolean isConcatenation()
public boolean isAlternation()
public boolean isPermutation()
public boolean isLambda()
public void branch(int position)
Converts the i-th position of this concatenation to alternation and inserts the rest as the one and only of its children.
Example: consider concatenation :
(A B C D)
after applying branch(2)
it will
look like this:
(A B (C D | ))
If i-th position is already an alternation, nothing happens.
Note that elements of the concatenation are indexed from 0.
position
- Where to branch.public Regexp<T> getEnd(int from)
from
up to the end.
from
- Index from which to start taking the suffix.
public String toString()
toString
in class Object
|
jInfer | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |