Package eu.bandm.tools.ramus.ogma
Class AbstractExpression<D,T,A>
java.lang.Object
eu.bandm.tools.ramus.ogma.AbstractExpression<D,T,A>
- Type Parameters:
D- the type of document identifiersT- the type of token typesA- the type of parsing results
Base class for syntax–semantics pairs.
Subclasses differ in how the results are stored in semantic states.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractExpression(Parser<D, T> syntax, Data.View<A> semantics, State.Projection projection) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionassign()Returns a fragment that has the syntax and semantics of this expression and assigns the result of this expression to a fresh key.Returns a fragment that has the syntax and semantics of this expression and assigns the result of this expression to the given key.Returns the operation that extracts the result data for this expression from a semantic state.Returns the data view that specifies the semantic result of this expression.Returns the parser that specifies the syntax of this expression.
-
Constructor Details
-
AbstractExpression
protected AbstractExpression(Parser<D, T> syntax, Data.View<A> semantics, State.Projection projection) Creates a new instance.- Parameters:
syntax- the parser that specifies the syntaxsemantics- the data view that specifies the semantic resultprojection- the operation that extracts the result data from a semantic state- Throws:
NullPointerException- if any parameter is null
-
-
Method Details
-
getSyntax
Returns the parser that specifies the syntax of this expression.- Returns:
- the parser that specifies the syntax
-
getSemantics
Returns the data view that specifies the semantic result of this expression.- Returns:
- the data view that specified the semantic result
-
getProjection
Returns the operation that extracts the result data for this expression from a semantic state.- Returns:
- the operation that extracts the result data
-
assign
Returns a fragment that has the syntax and semantics of this expression and assigns the result of this expression to the given key.The initial value associated with the key is the empty optional,
Data.none().- Parameters:
key- the key to assign the result to- Returns:
- a fragment that has the syntax and semantics of this expression and
assigns the result of this expression to
key - Throws:
NullPointerException- ifkeyis null
-
assign
Returns a fragment that has the syntax and semantics of this expression and assigns the result of this expression to a fresh key.The key used by the resulting fragment is not publicly visible. Hence its result can only be retrieved via
State.project(AbstractExpression).- Returns:
- a fragment that has the syntax and semantics of this expression and assigns the result of this expression to a fresh key
-