Class Reading<D,T,A>
- Type Parameters:
D
- the type of document identifiersT
- the type of token typesA
- the type of parsing results
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Function for constructing binary AST nodes for operators.static class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <D,
T, A> Reading<D, T, A> Retrieve the value assigned to a given key as the semantic interpretation.andThenCombining
(Reading<D, T, B> other, BiFunction<? super A, ? super B, ? extends C> pair) Match the syntax of this expression followed by that of another, combining the semantic interpretations with a function.Match the syntax of this expression followed by that of another, combining the semantic interpretations.Match the syntax of this token with a suffix, with the same semantic interpretation.Match the syntax of this token with a suffix, with the same semantic interpretation.Match the syntax of this token with a suffix, with the same semantic interpretation.Match the same syntax as this expression, and assign the semantic interpretation to a given key.static <D,
T, A> Reading<D, T, A> static <D,
T, A> Reading<D, T, A> Match the given syntax with a constant semantic interpretation.static <D,
T, A> Reading<D, T, A> constant
(T type, A value) Match the given syntax with a constant semantic interpretation.static <D,
T, A> Reading<D, T, A> Match the given syntax with a constant semantic interpretation.static <D,
T, A> Reading<D, T, A> constantEpsilon
(A value) Match no input with a constant semantic interpretation.content
(T... types) Match a token of any of the given token types and interpret as its content.static <D,
T, A> Reading<D, T, A> counit
(A value) static <D,
T, A> Reading<D, T, A> Make a recursive expression.static <D,
T, A> Reading<D, T, A> ifThenElse
(T type, Reading<D, T, ? extends A> thenBranch, Reading<D, T, ? extends A> elseBranch) Choose between two expression depending on the type of the next token.static <D,
T, A> Reading<D, T, A> leftAssoc
(Reading.OperatorFactory<D, T, A> operator, Reading<D, T, A> operand, T... operatorTypes) Tactic for left-associative operators.static <D,
T, A> Reading<D, T, A> leftAssoc
(Reading<D, T, A> headOperand, Reading.OperatorFactory<D, T, A> operator, Reading<D, T, A> tailOperand, T... operatorTypes) static <D,
T, A> Reading<D, T, A> static <D,
T, A> Reading<D, T, A> static <D,
T, A> Reading<D, T, A> Match the same syntax as this expression, and apply a function to the result of semantic interpretation.Match the syntax of this expression followed by that of another, combining the semantic interpretations as aMap.Entry
.static <D,
T, A> Reading<D, T, A> nonAssoc
(Reading.OperatorFactory<D, T, A> operator, Reading<D, T, A> operand, T... operatorTypes) Tactic for non-associative operators.optional
(Parser.Pragma... pragmas) Match the syntax of this token with the same interpretation, or otherwise match no input.Match the syntax of this token with the same interpretation, or otherwise match no input.orElse
(A defaultValue, Parser.Pragma... pragmas) Match the syntax of this token with the same interpretation, or otherwise match no input with the given default interpretation.orElseGet
(Supplier<? extends A> defaultValue, Parser.Pragma... pragmas) Match the syntax of this token with the same interpretation, or otherwise match no input with the given default interpretation.plus
(Parser.Pragma... pragmas) Match one or more repetitions of this expression.plus
(Parser<D, T> sep, Parser.Pragma... pragmas) Match one or more repetitions of this expression with intervening separator syntax.plus
(T sep, Parser.Pragma... pragmas) Match one or more repetitions of this expression with intervening separator syntax.Match the syntax of this token with a prefix, with the same semantic interpretation.Match the syntax of this token with a prefix, with the same semantic interpretation.Match the syntax of this token with a prefix, with the same semantic interpretation.process
(Parser.Input<D, T> in) static <D,
T, A> Reading<D, T, A> rightAssoc
(Reading.OperatorFactory<D, T, A> operator, Reading<D, T, A> operand, T... operatorTypes) Tactic for right-associative operators.star
(Parser.Pragma... pragmas) Match zero or more repetitions of this expression.star
(Parser<D, T> sep, Parser.Pragma... pragmas) Match zero or more repetitions of this expression with intervening separator syntax.star
(T sep, Parser.Pragma... pragmas) Match zero or more repetitions of this expression with intervening separator syntax.text
(T... types) Match a token of any of the given token types and interpret as its text.toString()
static <D,
T> Reading<D, T, T> type
(T... types) Match a token of any of the given token types and interpret as its type.unit()
Match no input with no semantic interpretation.Match the given syntax with no semantic interpretation.unit
(T... types) Match the given syntax with no semantic interpretation.withOtherTokenSource
(LookaheadTokenMultiplexer<K, D, T, L> multi, K newKey) Match the same syntax as this expression, but perform semantic interpretation in a local scope.Match the syntax of this token with a prefix and a suffix, with the same semantic interpretation.Match the syntax of this token with a prefix and a suffix, with the same semantic interpretation.Methods inherited from class eu.bandm.tools.ramus.runtime2.AbstractExpression
assign, assign, getProjection, getSemantics, getSyntax
-
Constructor Details
-
Reading
-
-
Method Details
-
toString
-
content
-
content
Match a token of any of the given token types and interpret as its content.- Type Parameters:
D
- the type of document identifiersT
- the type of token types
-
type
Match a token of any of the given token types and interpret as its type.- Type Parameters:
D
- the type of document identifiersT
- the type of token types
-
text
Match a token of any of the given token types and interpret as its text.- Type Parameters:
D
- the type of document identifiersT
- the type of token types
-
map
Match the same syntax as this expression, and apply a function to the result of semantic interpretation. -
prepend
Match the syntax of this token with a prefix, with the same semantic interpretation. The prefix must be present, but does not contribute to interpretation. -
prepend
Match the syntax of this token with a prefix, with the same semantic interpretation. The prefix must be present, but does not contribute to interpretation. -
append
Match the syntax of this token with a suffix, with the same semantic interpretation. The suffix must be present, but does not contribute to interpretation. -
append
Match the syntax of this token with a suffix, with the same semantic interpretation. The suffix must be present, but does not contribute to interpretation. -
prepend
Match the syntax of this token with a prefix, with the same semantic interpretation. The prefix must be present, but does not contribute to interpretation. -
append
Match the syntax of this token with a suffix, with the same semantic interpretation. The suffix must be present, but does not contribute to interpretation. -
wrap
Match the syntax of this token with a prefix and a suffix, with the same semantic interpretation. The prefix and suffix must be present, but do not contribute to interpretation. -
wrap
Match the syntax of this token with a prefix and a suffix, with the same semantic interpretation. The prefix and suffix must be present, but do not contribute to interpretation. -
orElse
Match the syntax of this token with the same interpretation, or otherwise match no input with the given default interpretation. -
orElseGet
Match the syntax of this token with the same interpretation, or otherwise match no input with the given default interpretation. -
optional
Match the syntax of this token with the same interpretation, or otherwise match no input.Whether input has been matched or not is reflected in the
Optional
interpretation result. -
optional
Match the syntax of this token with the same interpretation, or otherwise match no input.Whether input has been matched or not is reflected in the
Optional
interpretation result. -
star
Match zero or more repetitions of this expression.The interpretation results are collected in a
List
. -
star
Match zero or more repetitions of this expression with intervening separator syntax.The interpretation results are collected in a
List
. -
star
Match zero or more repetitions of this expression with intervening separator syntax.The interpretation results are collected in a
List
. -
plus
Match one or more repetitions of this expression.The interpretation results are collected in a non-empty
List
. -
plus
Match one or more repetitions of this expression with intervening separator syntax.The interpretation results are collected in a non-empty
List
. -
plus
Match one or more repetitions of this expression with intervening separator syntax.The interpretation results are collected in a non-empty
List
. -
constant
Match the given syntax with a constant semantic interpretation. -
constant
Match the given syntax with a constant semantic interpretation. -
constant
Match the given syntax with a constant semantic interpretation. -
constantEpsilon
Match no input with a constant semantic interpretation. -
choice
-
orElse
-
lookup
-
lookup
-
lookahead
-
andThenCombining
public <B,C> Reading<D,T, andThenCombiningC> (Reading<D, T, B> other, BiFunction<? super A, ? super B, ? extends C> pair) Match the syntax of this expression followed by that of another, combining the semantic interpretations with a function. -
mapsTo
Match the syntax of this expression followed by that of another, combining the semantic interpretations as aMap.Entry
. -
andThenDependent
Match the syntax of this expression followed by that of another, combining the semantic interpretations. -
fix
Make a recursive expression. -
unit
Match the given syntax with no semantic interpretation. -
unit
Match the given syntax with no semantic interpretation. -
unit
Match no input with no semantic interpretation. -
counit
-
ifThenElse
public static <D,T, Reading<D,A> T, ifThenElseA> (T type, Reading<D, T, ? extends A> thenBranch, Reading<D, T, ? extends A> elseBranch) Choose between two expression depending on the type of the next token. -
access
Retrieve the value assigned to a given key as the semantic interpretation.No input tokens are matched.
- Type Parameters:
D
- the type of document identifiersT
- the type of token typesA
- the type of parsing results- Parameters:
type
- the expected type of the valuekey
- the key- See Also:
-
assigning
Match the same syntax as this expression, and assign the semantic interpretation to a given key.- Parameters:
key
- the key- See Also:
-
withScope
Match the same syntax as this expression, but perform semantic interpretation in a local scope.All assignments to keys performed by the this expression are undone afterwards.
- Parameters:
initializers
- a map of initial local values for some keys- See Also:
-
guard
-
process
-
process
-
leftAssoc
public static <D,T, Reading<D,A> T, leftAssocA> (Reading.OperatorFactory<D, T, A> operator, Reading<D, T, A> operand, T... operatorTypes) Tactic for left-associative operators.The resulting expression will match inputs of the form "e1 op1 ... opn-1 en", and interpret them as an AST of the form opn-1(... op1(e1, e2) ..., en).
It is assumed that all operands ei conform to the same syntax and interpretation, and that operators are distinguished by token type.
- Type Parameters:
D
- the type of document identifiersT
- the type of token typesA
- the type of parsing results- Parameters:
operator
- a function to construct binary AST nodes for operatorsoperand
- the expression for operandsoperatorTypes
- an array containing the token types that denote operators- See Also:
-
leftAssoc
public static <D,T, Reading<D,A> T, leftAssocA> (Reading<D, T, A> headOperand, Reading.OperatorFactory<D, T, A> operator, Reading<D, T, A> tailOperand, T... operatorTypes) -
rightAssoc
public static <D,T, Reading<D,A> T, rightAssocA> (Reading.OperatorFactory<D, T, A> operator, Reading<D, T, A> operand, T... operatorTypes) Tactic for right-associative operators.The resulting expression will match inputs of the form "e1 op1 ... opn-1 en", and interpret them as an AST of the form op1(e1, ... opn-1(en-1, en)...).
It is assumed that all operands ei conform to the same syntax and interpretation, and that operators are distinguished by token type.
- Type Parameters:
D
- the type of document identifiersT
- the type of token typesA
- the type of parsing results- Parameters:
operator
- a function to construct binary AST nodes for operatorsoperand
- the expression for operandsoperatorTypes
- an array containing the token types that denote operators- See Also:
-
nonAssoc
public static <D,T, Reading<D,A> T, nonAssocA> (Reading.OperatorFactory<D, T, A> operator, Reading<D, T, A> operand, T... operatorTypes) Tactic for non-associative operators.The resulting expression will match inputs of the form "e1 op e2", and interpret them as an AST of the form op(e1, e2).
It is assumed that all operands ei conform to the same syntax and interpretation, and that operators are distinguished by token type.
- Type Parameters:
D
- the type of document identifiersT
- the type of token typesA
- the type of parsing results- Parameters:
operator
- a function to construct binary AST nodes for operatorsoperand
- the expression for operandsoperatorTypes
- an array containing the token types that denote operators- See Also:
-
withOtherTokenSource
-