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 ... Rn
Then the function will be called at a certain stage
k
, wherek
is the number of symbolsR1
…Rk
whose parameters have already been computed during previous stages.Seealso
Rule
Declaration
Swift
public typealias EvalFunc<Param> = (_ env: EvalEnv, _ k: Int, _ params: [Param]) -> Param?
Parameters
env
An 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.
k
The current stage, where
0 <= k <= n
, andn
is the number of symbols on the right hand side of the rule.params
The parameters that have been evaluated so far. We have
params.count == 1 + 2 * k
and the following layout:params[0]
: the input parameter ofL
params[1]
: the input parameter ofR1
params[2]
: the output parameter ofR1
params[3]
: the input parameter ofR2
params[4]
: the output parameter ofR2
- …
params[2*k-1]
: the input parameter ofRk
params[2*k]
: the output parameter ofRk
Return Value
For
k < n
this returns the input parameter ofR(k+1)
. Fork == n
this 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.rules
array.Declaration
Swift
public typealias RuleIndex = Int