public abstract class EvaluatingAlgebra<E> extends Algebra<E>
evaluate(java.lang.String, java.util.List)
method to assign a semantics to these symbols.
The algebra
class then provides generic decomposition automata for these
algebras. The states of these decomposition automata are values
of E. They implement
TreeAutomaton.getRulesBottomUp(int, java.util.List)
by simply
applying the algebra operation specified by the terminal symbol
to the algebra objects specified by the child states.
Notice that
the decomposition automata do not implement TreeAutomaton.getRulesTopDown(int, int)
,
so you need to avoid using methods that access rules top-down.
You should also expect that a parser using these generic
decomposition automata are not particularly efficient.
See SetAlgebra
for a use case of this class.
Constructor and Description |
---|
EvaluatingAlgebra()
Creates a new instance that will have a new signature.
|
Modifier and Type | Method and Description |
---|---|
TreeAutomaton |
decompose(E value)
Computes a decomposition automaton for the given value.
|
E |
evaluate(Tree<String> t)
Evaluates a term over the algebra's signature into an algebra object.
|
Signature |
getSignature()
Returns the signature of this algebra.
|
abstract E |
parseString(String representation)
Resolves the string representation of some element of the algebra's
domain to this element.
|
getAllAlgebraClasses, getClassOfValues, hasOptions, readOptions, representAsString, setOptions, visualize, writeOptions
public EvaluatingAlgebra()
public abstract E parseString(String representation) throws ParserException
Algebra
TreeAlgebra.parseString(java.lang.String)
resolves the string "f(a,b)" into a tree with three nodes.It is the job of an algebra class to keep track of the signature of the algebra. Many algebras have a potentially infinite domain (e.g. the string algebra can be used with arbitrary alphabets), so the algebra class should keep track of the symbols that were actually used in the current run of the program. The best practice is to update the signature each time the parseString method is called. The rest of the IRTG tool code takes care to call parseString of the respective algebra to obtain objects of type E, so this ensures that the signature is always up-to-date.
parseString
in class Algebra<E>
ParserException
public E evaluate(Tree<String> t)
Algebra
public TreeAutomaton decompose(E value)
Algebra
public Signature getSignature()
Algebra
getSignature
in class Algebra<E>
Copyright © 2017. All rights reserved.