Type Aliases
The following type aliases are available globally.
-
A function which is used to compute the parameters of the involved symbols during the parsing progress of an invocation of a rule.
Assume that the rule has the form
L => R1 R2 ... RnThen the function will be called at a certain stage
k, wherekis the number of symbolsR1…Rkwhose parameters have already been computed during previous stages.Seealso
RuleDeclaration
Swift
public typealias EvalFunc<Param> = (_ env: EvalEnv, _ k: Int, _ params: [Param]) -> Param?Parameters
envAn environment which a function can use to store information in between calls to it during the parsing progress of the rule as it progresses from stage to stage. The environment is a copy of an environment used during the previous stage.
kThe current stage, where
0 <= k <= n, andnis the number of symbols on the right hand side of the rule.paramsThe parameters that have been evaluated so far. We have
params.count == 1 + 2 * kand the following layout:params[0]: the input parameter ofLparams[1]: the input parameter ofR1params[2]: the output parameter ofR1params[3]: the input parameter ofR2params[4]: the output parameter ofR2- …
params[2*k-1]: the input parameter ofRkparams[2*k]: the output parameter ofRk
Return Value
For
k < nthis returns the input parameter ofR(k+1). Fork == nthis returns the output parameter ofL. In case of a return value ofnil, the parsing at this particular stage is aborted. -
Represents the result of parsing a set of terminals at the same position. Each terminal and associated input parameter under consideration is mapped to its set of successfully parsed tokens.
Declaration
Swift
public typealias Tokens<Param, Result> = [TerminalKey<Param> : Set<Token<Param, Result>>] where Param : Hashable -
The index of a rule in the
Grammar.rulesarray.Declaration
Swift
public typealias RuleIndex = Int
Type Aliases Reference