Class LogicExpressionParser<E>
java.lang.Object
edu.washington.cs.knowitall.logic.LogicExpressionParser<E>
- Type Parameters:
E
- the type of the base expressions
- All Implemented Interfaces:
com.google.common.base.Function<String,
,LogicExpression<E>> Function<String,
LogicExpression<E>>
public abstract class LogicExpressionParser<E>
extends Object
implements com.google.common.base.Function<String,LogicExpression<E>>
A logic expression engine that operates over user specified objects.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Expression.Arg
<E> The factory method creates an argument from the supplied token string.Create a LogicExpression object from the supplied string.The readToken method reads a token from the remaining LogicExpression string.List
<Expression<E>> Convert an infix string logic representation to an infix list of tokens.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
-
Field Details
-
doubleQuoteStringLiteralRegex
-
singleQuoteStringLiteralRegex
-
regexLiteralRegex
-
literalPatterns
-
-
Constructor Details
-
LogicExpressionParser
public LogicExpressionParser()
-
-
Method Details
-
parse
Create a LogicExpression object from the supplied string.- Parameters:
string
-- Returns:
-
apply
- Specified by:
apply
in interfacecom.google.common.base.Function<String,
LogicExpression<E>> - Specified by:
apply
in interfaceFunction<String,
LogicExpression<E>>
-
factory
The factory method creates an argument from the supplied token string.- Parameters:
argument
- a string representation of a token- Returns:
- an evaluatable representation of a token
-
readToken
The readToken method reads a token from the remaining LogicExpression string. A token may contain a string. If it contains parentheses, the token will last until the parentheses are balanced. And invalid input: '&', |, or unbalanced ) will mark the end of a token. This is a default implementation that may be overriden.- Parameters:
remainder
- the remaining text to tokenize- Returns:
- a token from the beginning on `remaining`
-
tokenize
Convert an infix string logic representation to an infix list of tokens.- Parameters:
input
- an infix string logic representation.factory
- a delegate that converts a string representation of an argument into a token object. @return- Throws:
LogicException.TokenizeLogicException
-