Package eu.bandm.tools.ramus.ogma
Class Fragment<D,T,A>
java.lang.Object
eu.bandm.tools.ramus.ogma.AbstractExpression<D,T,A>
eu.bandm.tools.ramus.ogma.Fragment<D,T,A>
- Type Parameters:
D- the type of document identifiersT- the type of token typesA- the type of parsing results
A syntax–semantics pair that stores the result in a variable.
Fragments are useful for recording semantic results in passing, and use them later.
- See Also:
-
Constructor Summary
Constructors -
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.endInterval(ParserFactory factory) Returns a fragment that sets the result value to the token location before the current input state.final DataReturns the initial value for the result of this fragment.final ObjectgetKey()Returns the key for the result of this fragment.imported()Returns a variant of this fragment that imports the result from an enclosing scope.final booleanChecks whether this fragment imports the result from an enclosing scope.startInterval(ParserFactory factory) Returns a fragment that sets the result value to the token location at the current input state.Methods inherited from class eu.bandm.tools.ramus.ogma.AbstractExpression
assign, getProjection, getSemantics, getSyntax
-
Constructor Details
-
Fragment
Creates a new fragment.The initial value associated with the key is the empty optional,
Data.none().The semantic effect of storing the result value is added implicitly to the given parser.
- Parameters:
key- the key for the resultbaseSyntax- the parser that specifies the syntax, and leaves the result value in the accumulatorsemantics- the data view that specifies the semantic result- Throws:
NullPointerException- if any parameter is null
-
Fragment
Creates a new fragment.The semantic effect of storing the result value is added implicitly to the given parser.
- Parameters:
key- the key for the resultinitialValue- the initial value associated with the keybaseSyntax- the parser that specifies the syntax, and leaves the result value in the accumulatorsemantics- the data view that specifies the semantic result- Throws:
NullPointerException- if any parameter is null
-
-
Method Details
-
getKey
Returns the key for the result of this fragment.- Returns:
- the key for the result of this fragment
-
getInitialValue
Returns the initial value for the result of this fragment.- Returns:
- the initial value for the result of this fragment
-
isImported
public final boolean isImported()Checks whether this fragment imports the result from an enclosing scope.- Returns:
trueif this fragment imports the result from an enclosing scope;falseif the result is obtained by parsing- See Also:
-
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).- Overrides:
assignin classAbstractExpression<D,T, A> - Returns:
this
-
imported
Returns a variant of this fragment that imports the result from an enclosing scope.The resulting fragment has no syntax of its own; the result is retrieved from an earlier parsing.
If this fragment is already imported, it is returned directly.
- Returns:
- a variant of this fragment that imports the result from an enclosing scope
- See Also:
-
startInterval
Returns a fragment that sets the result value to the token location at the current input state.- Type Parameters:
D- the type of source document identifiersT- the type of token types; typically an enum type- Returns:
- a fragment that sets the result value to the token location at the current input state.
-
endInterval
Returns a fragment that sets the result value to the token location before the current input state.- Type Parameters:
D- the type of source document identifiersT- the type of token types; typically an enum type- Returns:
- a fragment that sets the result value to the token location before the current input state.
-