E
- the type of the sequence elementspublic class RegularExpression<E>
extends java.lang.Object
implements com.google.common.base.Predicate<java.util.List<E>>
Modifier and Type | Field and Description |
---|---|
FiniteAutomaton.Automaton<E> |
auto |
java.util.List<Expression<E>> |
expressions |
Constructor and Description |
---|
RegularExpression(java.util.List<Expression<E>> expressions) |
Modifier and Type | Method and Description |
---|---|
boolean |
apply(java.util.List<E> tokens)
Apply the expression against a list of tokens.
|
static <E> FiniteAutomaton.Automaton<E> |
build(java.util.List<Expression<E>> exprs)
Build an NFA from the list of expressions.
|
static <E> RegularExpression<E> |
compile(java.util.List<Expression<E>> expressions)
Create a regular expression without tokenization support.
|
static <E> RegularExpression<E> |
compile(java.lang.String expression,
com.google.common.base.Function<java.lang.String,Expression.BaseExpression<E>> factoryDelegate)
Create a regular expression from the specified string.
|
boolean |
equals(java.lang.Object other) |
Match<E> |
find(java.util.List<E> tokens)
Find the first match of the regular expression against tokens.
|
Match<E> |
find(java.util.List<E> tokens,
int start)
Find the first match of the regular expression against tokens, starting
at the specified index.
|
java.util.List<Match<E>> |
findAll(java.util.List<E> tokens)
Find all non-overlapping matches of the regular expression against tokens.
|
int |
hashCode() |
Match<E> |
lookingAt(java.util.List<E> tokens)
Determine if the regular expression matches the beginning of the
supplied tokens.
|
Match<E> |
lookingAt(java.util.List<E> tokens,
int start)
Determine if the regular expression matches the supplied tokens,
starting at the specified index.
|
static void |
main(java.lang.String[] args)
An interactive program that compiles a word-based regular expression
specified in arg1 and then reads strings from stdin, evaluating them
against the regular expression.
|
Match<E> |
match(java.util.List<E> tokens) |
boolean |
matches(java.util.List<E> tokens)
Apply the expression against a list of tokens.
|
java.lang.String |
toString() |
public final java.util.List<Expression<E>> expressions
public final FiniteAutomaton.Automaton<E> auto
public RegularExpression(java.util.List<Expression<E>> expressions)
public static <E> RegularExpression<E> compile(java.util.List<Expression<E>> expressions)
expressions
- public static <E> RegularExpression<E> compile(java.lang.String expression, com.google.common.base.Function<java.lang.String,Expression.BaseExpression<E>> factoryDelegate)
expression
- factoryDelegate
- public boolean equals(java.lang.Object other)
equals
in interface com.google.common.base.Predicate<java.util.List<E>>
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static <E> FiniteAutomaton.Automaton<E> build(java.util.List<Expression<E>> exprs)
exprs
- public boolean apply(java.util.List<E> tokens)
apply
in interface com.google.common.base.Predicate<java.util.List<E>>
public boolean matches(java.util.List<E> tokens)
public Match<E> find(java.util.List<E> tokens)
tokens
- public Match<E> find(java.util.List<E> tokens, int start)
tokens
- tokens to match against.start
- index to start looking for a match.public Match<E> lookingAt(java.util.List<E> tokens)
tokens
- the list of tokens to match.public Match<E> lookingAt(java.util.List<E> tokens, int start)
tokens
- the list of tokens to match.start
- the index where the match should begin.public java.util.List<Match<E>> findAll(java.util.List<E> tokens)
tokens
- public static void main(java.lang.String[] args)
args
-