Class RegularExpressionParser<E>
java.lang.Object
edu.washington.cs.knowitall.regex.RegularExpressionParser<E>
- Type Parameters:
E
- the type of the sequence elements
- All Implemented Interfaces:
com.google.common.base.Function<String,
,RegularExpression<E>> Function<String,
RegularExpression<E>>
public abstract class RegularExpressionParser<E>
extends Object
implements com.google.common.base.Function<String,RegularExpression<E>>
A regular expression parser turns strings into RegularExpression
objects.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Expression.BaseExpression<E>
The factory method creates an expression from the supplied token string.private static int
indexOfClose
(String string, int start, char open, char close) Read a token from the remaining text and return it.List<Expression<E>>
Convert a list of tokens (<...>) to a list of expressions.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.common.base.Function
equals
-
Constructor Details
-
RegularExpressionParser
public RegularExpressionParser()
-
-
Method Details
-
factory
The factory method creates an expression from the supplied token string.- Parameters:
token
- a string representation of a token- Returns:
- an evaluatable representation of a token
-
parse
-
apply
- Specified by:
apply
in interfacecom.google.common.base.Function<String,
RegularExpression<E>> - Specified by:
apply
in interfaceFunction<String,
RegularExpression<E>>
-
readToken
Read a token from the remaining text and return it. This is a default implementation that is overridable. In the default implementation, the starting and ending token characters are not escapable. If this implemenation is overridden, A token MUST ALWAYS start with '<' or '[' and end with '>' or ']'.- Parameters:
remaining
-- Returns:
-
tokenize
Convert a list of tokens (<...>) to a list of expressions.- Parameters:
tokens
-factory
- Factory class to create a BaseExpression from the text between angled brackets.- Returns:
-
indexOfClose
-