ConstructResult
public protocol ConstructResult : GrammarComponent
A ConstructResult
is a specification for how to compute the result of a successful parse.
-
The type of characters of the input being parsed.
Declaration
Swift
associatedtype Char
-
Constructs the result of a successful invocation of a parse rule.
Declaration
Swift
func evalRule<RHS>(input: Input<Char>, key: ItemKey<Param>, completed: RHS) -> Result where RHS : CompletedRightHandSide, Self.Param == RHS.Param, Self.Result == RHS.Result
Parameters
input
The input, part of which has been successfully parsed.
key
This key designates which part of the input has been parsed as what symbol.
completed
Information about the completed right-hand side of the rule.
Return Value
The result.
-
Constructs the result from a terminal result.
Declaration
Swift
func terminal(key: ItemKey<Param>, result: Result?) -> Result
Parameters
key
The key for which this terminal has been parsed successfully.
result
The result of parsing / lexing the terminal.
Return Value
The result.
-
This is called to merge all results for that particular
key
into a single result.Declaration
Swift
func merge(key: ItemKey<Param>, results: [Result]) -> Result
Parameters
key
The key for which parsing has completed successfully.
results
The results of all successful parses for the particular
key
under consideration. If all such parses have returned anil
result, thenresults
will be empty.Return Value
An result that represents the merge of
results
. -
Undocumented
Declaration
Swift
func nameOf(symbol: Symbol) -> String