E - the type of the base expressionspublic class LogicExpression<E> extends Object implements com.google.common.base.Predicate<E>
| Modifier | Constructor and Description |
|---|---|
protected |
LogicExpression(List<Expression<E>> expressions) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
apply(E entity) |
static <E> Expression.Apply<E> |
buildAst(List<Expression<E>> rpn)
Compile a rpn list of tokens into an expression tree.
|
static <E> LogicExpression<E> |
compile(List<Expression<E>> expressions)
Compile an infix list of tokens into an expression tree.
|
static <E> LogicExpression<E> |
compile(String input,
com.google.common.base.Function<String,Expression.Arg<E>> factoryDelegate)
Helper factory method to instantiate a LogicExpression.
|
List<String> |
getArgs()
Return a list of the arguments contained in the expression.
|
boolean |
isEmpty()
If the expression is empty, it returns true for all inputs.
|
static void |
main(String[] args)
Iteractively interpret logic statements from stdin such as "true | (true & false)".
|
List<Expression<E>> |
rpn(List<Expression<E>> tokens)
Converts an infix logic representation into a postfix logic representation.
|
String |
toString() |
protected LogicExpression(List<Expression<E>> expressions) throws LogicException.TokenizeLogicException, LogicException.CompileLogicException
input - an infix representation of the logic expression.LogicException.TokenizeLogicExceptionLogicException.CompileLogicExceptionpublic static <E> LogicExpression<E> compile(List<Expression<E>> expressions)
rpn - a list of tokens in infix form.public static <E> LogicExpression<E> compile(String input, com.google.common.base.Function<String,Expression.Arg<E>> factoryDelegate)
input - The string to parse.factoryDelegate - The factory to build tokens.public boolean isEmpty()
public boolean apply(E entity)
apply in interface com.google.common.base.Predicate<E>public static <E> Expression.Apply<E> buildAst(List<Expression<E>> rpn)
rpn - a list of tokens in infix form.public List<String> getArgs()
public List<Expression<E>> rpn(List<Expression<E>> tokens) throws LogicException.CompileLogicException
tokens - a list of tokens in infix form.LogicException.CompileLogicExceptionpublic static void main(String[] args)
args - Copyright © 2010–2013 University of Washington CSE. All rights reserved.