@configuredthings/rdp.js - v0.7.0
    Preparing search index...

    Class EBNFParser

    Hierarchy

    • GrammarParser
      • EBNFParser
    Index

    Constructors

    Properties

    source: DataView

    The raw input buffer. Accessible to subclasses so they can decode slices.

    Methods

    • Moves the current position forward by one byte. Has no effect when already at end of input.

      Returns void

    • Returns true when the parser has reached the end of input. Implemented by subclasses based on their input representation.

      Returns boolean

    • Returns a zero-copy DataView slice of the source buffer.

      Parameters

      • from: number

        Start byte offset (inclusive), relative to the start of source.

      • to: number

        End byte offset (exclusive), relative to the start of source.

      Returns DataView

    • Returns the byte at the current position and advances past it.

      Returns number

      If already at end of input.

    • Decodes a byte range of the source buffer as a UTF-8 string.

      Parameters

      • from: number

        Start offset (inclusive).

      • to: number

        End offset (exclusive).

      Returns string

    • Returns a human-readable description of the input element at pos for use in error messages. In scannerless parsers this describes a byte; in token parsers it describes a token.

      Parameters

      • pos: number

        The position index to describe.

      Returns string

    • Throws an RDParserException with the given message and the current position appended. The return type is never so call sites can write return this.error(...) to satisfy TypeScript's control-flow analysis.

      Parameters

      • message: string

        Description of the parse failure.

      Returns never

      Always.

    • Throws a RDParserException naming the unexpected input element at the furthest position reached during parsing.

      Call this from the top-level parse() method when the first rule returns null, to give callers a precise error location rather than a generic "Failed to parse input (at position 0)" message.

      Returns never

      Always.

    • Asserts that the current byte equals expectedByte and consumes it.

      Parameters

      • expectedByte: number

        The byte value expected.

      • OptionalexpectedCharDescription: string

        Optional human-readable name for the expected character.

      Returns void

      If the current byte does not match expectedByte.

    • Returns the furthest position at which a terminal match was attempted and failed. Useful for producing informative error messages when the overall parse fails.

      Returns number

    • Returns the current position within the input.

      Returns number

    • Returns true if byte is an ASCII letter (A–Z or a–z).

      Parameters

      • byte: number | null

      Returns byte is number

    • Returns true if byte is an ASCII digit (0–9).

      Parameters

      • byte: number | null

      Returns byte is number

    • Returns true if byte is a valid ASCII hex digit (0–9, A–F, a–f).

      Parameters

      • byte: number | null

      Returns byte is number

    • EBNF names allow underscore, letters, digits, and hyphen.

      Parameters

      • byte: number | null

      Returns byte is number

    • EBNF names allow underscore in addition to letters.

      Parameters

      • byte: number | null

      Returns byte is number

    • If the current byte equals expectedByte, consumes it and returns true. Otherwise leaves the position unchanged and returns false.

      Parameters

      • expectedByte: number

        The byte value to match.

      Returns boolean

    • Returns the byte at the current position without consuming it, or null if the parser has reached the end of input.

      Returns number | null

    • If the current byte equals expectedByte, consumes it and returns it as a one-character string. Otherwise leaves the position unchanged and returns null.

      This is the value-returning counterpart of matchChar, used by generated parsers to capture terminal characters directly into the parse tree.

      Parameters

      • expectedByte: number

        The byte value to match.

      Returns string | null

    • If the current byte falls within [lowerBound, upperBound] (inclusive), consumes it and returns it as a one-character string. Otherwise leaves the position unchanged and returns null.

      Used by generated parsers to capture character-range terminals into the parse tree.

      Parameters

      • lowerBound: number

        Lower bound (inclusive) of the byte range.

      • upperBound: number

        Upper bound (inclusive) of the byte range.

      Returns string | null

    • Restores the current position to a previously saved value.

      Used with getPosition to implement backtracking in parser alternatives.

      Parameters

      • pos: number

        The position to restore to.

      Returns void

    • Records the current position as a fail point if it is further than any previously recorded fail. Subclasses call this when a terminal match fails.

      Returns void