Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    Class RollParser

    A class for transforming events from the Peggy grammar lexer into various formats.

    Index

    Constructors

    • Parameters

      • formula: string

        The full formula.

      Returns RollParser

    Properties

    formula: string

    The full formula.

    Methods

    • Protected

      Collapse multiple additive operators into a single one.

      Parameters

      • operators: string[]

        A sequence of additive operators.

      Returns string

    • Protected

      Handle a dice term.

      Parameters

      • number: RollParseNode | null

        The number of dice.

      • faces: string | RollParseNode | null

        The number of die faces or a string denomination like "c" or "f".

      • modifiers: string | null

        The matched modifiers string.

      • flavor: string | null

        Associated flavor text.

      • formula: string

        The original matched text.

      • offset: RollParseOffset

        The position of the matched term in the formula string.

      Returns RollParseNode

    • Protected

      Handle a base roll expression.

      Parameters

      • head: RollParseNode

        The first operand.

      • tail: [string[], RollParseNode][]

        Zero or more subsequent (operators, operand) tuples.

      • Optionalleading: string

        A leading operator.

      • formula: string

        The original matched text.

      • error: Function

        The peggy error callback to invoke on a parse error.

      Returns RollParseNode

    • Protected

      Handle a math term.

      Parameters

      • fn: string

        The Math function.

      • head: RollParseNode

        The first term.

      • tail: RollParseNode[]

        Zero or more additional terms.

      • flavor: string

        Associated flavor text.

      • formula: string

        The original matched text.

      • offset: RollParseOffset

        The position of the matched term in the formula string.

      Returns RollParseNode

    • Protected

      Handle a numeric term.

      Parameters

      • number: number

        The number.

      • flavor: string

        Associated flavor text.

      • offset: RollParseOffset

        The position of the matched term in the formula string.

      Returns RollParseNode

    • Protected

      Handle a parenthetical.

      Parameters

      • term: RollParseNode

        The inner term.

      • flavor: string | null

        Associated flavor text.

      • formula: string

        The original matched text.

      • offset: RollParseOffset

        The position of the matched term in the formula string.

      Returns RollParseNode

    • Protected

      Handle a pool term.

      Parameters

      • head: RollParseNode

        The first term.

      • tail: RollParseNode[]

        Zero or more additional terms.

      • modifiers: string | null

        The matched modifiers string.

      • flavor: string | null

        Associated flavor text.

      • formula: string

        The original matched text.

      • offset: RollParseOffset

        The position of the matched term in the formula string.

      Returns RollParseNode

    • Protected

      Handle some string that failed to be classified.

      Parameters

      • term: string

        The term.

      • Optionalflavor: string | null

        Associated flavor text.

      • offset: RollParseOffset

        The position of the matched term in the formula string.

      Returns StringParseNode

    • Format a parser argument.

      Parameters

      • arg: any

        The argument.

      Returns string

    • Format arguments for debugging.

      Parameters

      • method: string

        The method name.

      • ...args: any[]

        The arguments.

      Returns string

    • Format a list argument.

      Parameters

      • list: any[]

        The list to format.

      Returns string

    • Determine if a given node is an operator term.

      Parameters

      • node: any

      Returns boolean