Class AbstractExpression<D,T,A>

java.lang.Object
eu.bandm.tools.ramus.ogma.AbstractExpression<D,T,A>
Type Parameters:
D - the type of document identifiers
T - the type of token types
A - the type of parsing results
Direct Known Subclasses:
Fragment, Reading

public abstract class AbstractExpression<D,T,A> extends Object
Base class for syntax–semantics pairs.

Subclasses differ in how the results are stored in semantic states.

  • 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 syntax
      semantics - the data view that specifies the semantic result
      projection - the operation that extracts the result data from a semantic state
      Throws:
      NullPointerException - if any parameter is null
  • Method Details

    • getSyntax

      public Parser<D,T> getSyntax()
      Returns the parser that specifies the syntax of this expression.
      Returns:
      the parser that specifies the syntax
    • getSemantics

      public Data.View<A> getSemantics()
      Returns the data view that specifies the semantic result of this expression.
      Returns:
      the data view that specified the semantic result
    • getProjection

      public State.Projection 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

      public Fragment<D,T,A> assign(Object key)
      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 - if key is null
    • assign

      public Fragment<D,T,A> 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