Class Expression<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> Expression<D, T, A> Retrieve the value assigned to a given key as the semantic interpretation.<B,
C> Expression<D, T, C> andThenCombining
(Expression<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.<B> Expression<D,
T, B> andThenDependent
(Expression<D, T, Function<? super A, ? extends B>> other) Match the syntax of this expression followed by that of another, combining the semantic interpretations.Expression<D,
T, A> Match the syntax of this token with a suffix, with the same semantic interpretation.Expression<D,
T, A> Match the syntax of this token with a suffix, with the same semantic interpretation.final Expression<D,
T, A> Match the syntax of this token with a suffix, with the same semantic interpretation.Expression<D,
T, A> Match the same syntax as this expression, and assign the semantic interpretation to a given key.static <D,
T, A> Expression<D, T, A> choice
(Expression<D, T, ? extends A>... alts) static <D,
T, A> Expression<D, T, A> Match the given syntax with a constant semantic interpretation.static <D,
T, A> Expression<D, T, A> constant
(T type, A value) Match the given syntax with a constant semantic interpretation.static <D,
T, A> Expression<D, T, A> Match the given syntax with a constant semantic interpretation.static <D,
T, A> Expression<D, T, A> constantEpsilon
(A value) Match no input with a constant semantic interpretation.static <D,
T> Expression<D, T, Content<D, T>> static <D,
T> Expression<D, T, Content<D, T>> content
(T... types) Match a token of any of the given token types and interpret as its content.static <D,
T, A> Expression<D, T, A> counit
(A value) static <D,
T, A> Expression<D, T, A> fix
(Function<Expression<D, T, A>, Expression<D, T, A>> loop) Make a recursive expression.Expression<D,
T, A> static <D,
T, A> Expression<D, T, A> ifThenElse
(T type, Expression<D, T, ? extends A> thenBranch, Expression<D, T, ? extends A> elseBranch) Choose between two expression depending on the type of the next token.static <D,
T, A> Expression<D, T, A> leftAssoc
(Expression.OperatorFactory<D, T, A> operator, Expression<D, T, A> operand, T... operatorTypes) Tactic for left-associative operators.static <D,
T, A> Expression<D, T, A> leftAssoc
(Expression<D, T, A> headOperand, Expression.OperatorFactory<D, T, A> operator, Expression<D, T, A> tailOperand, T... operatorTypes) static <D,
T, A> Expression<D, T, A> lookahead
(Map<T, Expression<D, T, ? extends A>> map) static <D,
T, A> Expression<D, T, A> static <D,
T, A> Expression<D, T, A> <B> Expression<D,
T, B> Match the same syntax as this expression, and apply a function to the result of semantic interpretation.<B> Expression<D,
T, Map.Entry<A, B>> mapsTo
(Expression<D, T, B> other) Match the syntax of this expression followed by that of another, combining the semantic interpretations as aMap.Entry
.static <D,
T, A> Expression<D, T, A> nonAssoc
(Expression.OperatorFactory<D, T, A> operator, Expression<D, T, A> operand, T... operatorTypes) Tactic for non-associative operators.Expression<D,
T, Optional<A>> optional
(Parser.Pragma... pragmas) Match the syntax of this token with the same interpretation, or otherwise match no input.Expression<D,
T, Optional<A>> Match the syntax of this token with the same interpretation, or otherwise match no input.Expression<D,
T, A> 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.Expression<D,
T, A> orElse
(Expression<D, T, A> other) Expression<D,
T, A> 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.Expression<D,
T, List<A>> plus
(Parser.Pragma... pragmas) Match one or more repetitions of this expression.Expression<D,
T, List<A>> plus
(Parser<D, T> sep, Parser.Pragma... pragmas) Match one or more repetitions of this expression with intervening separator syntax.Expression<D,
T, List<A>> plus
(T sep, Parser.Pragma... pragmas) Match one or more repetitions of this expression with intervening separator syntax.Expression<D,
T, A> Match the syntax of this token with a prefix, with the same semantic interpretation.Expression<D,
T, A> Match the syntax of this token with a prefix, with the same semantic interpretation.final Expression<D,
T, A> Match the syntax of this token with a prefix, with the same semantic interpretation.process
(Parser.Input<D, T> in) static <D,
T, A> Expression<D, T, A> rightAssoc
(Expression.OperatorFactory<D, T, A> operator, Expression<D, T, A> operand, T... operatorTypes) Tactic for right-associative operators.Expression<D,
T, List<A>> star
(Parser.Pragma... pragmas) Match zero or more repetitions of this expression.Expression<D,
T, List<A>> star
(Parser<D, T> sep, Parser.Pragma... pragmas) Match zero or more repetitions of this expression with intervening separator syntax.Expression<D,
T, List<A>> star
(T sep, Parser.Pragma... pragmas) Match zero or more repetitions of this expression with intervening separator syntax.static <D,
T> Expression<D, T, String> text
(T... types) Match a token of any of the given token types and interpret as its text.toString()
static <D,
T> Expression<D, T, T> type
(T... types) Match a token of any of the given token types and interpret as its type.static <D,
T> Expression<D, T, Void> unit()
Match no input with no semantic interpretation.static <D,
T> Expression<D, T, Void> Match the given syntax with no semantic interpretation.static <D,
T> Expression<D, T, Void> unit
(T... types) Match the given syntax with no semantic interpretation.<K,
L> Expression<D, T, A> withOtherTokenSource
(LookaheadTokenMultiplexer<K, D, T, L> multi, K newKey) Expression<D,
T, A> Match the same syntax as this expression, but perform semantic interpretation in a local scope.Expression<D,
T, A> Match the syntax of this token with a prefix and a suffix, with the same semantic interpretation.Expression<D,
T, A> 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
-
Expression
-
-
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> Expression<D,T, andThenCombiningC> (Expression<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
public <B> Expression<D,T, andThenDependentB> (Expression<D, T, Function<? super A, ? extends B>> other) 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, Expression<D,A> T, ifThenElseA> (T type, Expression<D, T, ? extends A> thenBranch, Expression<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, Expression<D,A> T, leftAssocA> (Expression.OperatorFactory<D, T, A> operator, Expression<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, Expression<D,A> T, leftAssocA> (Expression<D, T, A> headOperand, Expression.OperatorFactory<D, T, A> operator, Expression<D, T, A> tailOperand, T... operatorTypes) -
rightAssoc
public static <D,T, Expression<D,A> T, rightAssocA> (Expression.OperatorFactory<D, T, A> operator, Expression<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, Expression<D,A> T, nonAssocA> (Expression.OperatorFactory<D, T, A> operator, Expression<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
public <K,L> Expression<D,T, withOtherTokenSourceA> (LookaheadTokenMultiplexer<K, D, T, L> multi, K newKey)
-