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, where k is the number of symbols R1Rk 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, and n 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 of L
    • params[1]: the input parameter of R1
    • params[2]: the output parameter of R1
    • params[3]: the input parameter of R2
    • params[4]: the output parameter of R2
    • params[2*k-1]: the input parameter of Rk
    • params[2*k]: the output parameter of Rk

    Return Value

    For k < n this returns the input parameter of R(k+1). For k == n this returns the output parameter of L. In case of a return value of nil, 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