Documentation
    Preparing search index...

    Class StringTokenParserExperimental

    A helper class for parsing strings into tokens. This class provides methods to consume or lookahead for specific pattern, with traceback support.

    Index

    Constructors

    Properties

    position: number = 0

    Current position in the source string.

    source: string

    The source string to be parsed.

    Accessors

    Methods

    • Experimental

      Checks if the state stack is empty. Throws an Error if not.

      Returns void

      If the state stack is not empty.

      This method is useful for ensuring that all states have been accepted or popped before finalizing the parsing process.

    • Experimental

      Consumes the first matching string from the provided iterable if it matches the current position. Advances the position if a match is found.

      Parameters

      • needles: Iterable<string>

        One or more strings to match.

      • Optionalcomparer: EqualityComparer<any>

        An optional equality comparer for custom string comparison.

      Returns undefined | string

      The matched string if successful; otherwise, undefined.

    • Experimental

      Consumes a regular expression match at the current position in the source. Advances the position if the match is successful.

      Parameters

      • needle: RegExp

        The regular expression to match. Must include the y (sticky) flag.

      Returns undefined | RegExpExecArray | RegExpMatchArray

      The match result if successful; otherwise, undefined.

    • Experimental

      Consumes the specified string if it matches the current position in the source. Advances the position if the match is successful.

      Parameters

      • needle: string

        The string to match.

      • Optionalcomparer: EqualityComparer<any>

        An optional equality comparer for custom string comparison.

      Returns boolean

      true if the string was successfully consumed; otherwise, false.

    • Experimental

      Checks if any of the provided strings match the current position in the source without consuming it.

      Parameters

      • needles: Iterable<string>

        One or more strings to match.

      • Optionalcomparer: EqualityComparer<any>

        An optional equality comparer for custom string comparison.

      Returns undefined | string

      The matched string if successful; otherwise, undefined.

    • Experimental

      Checks if a regular expression matches the current position in the source without consuming it.

      Parameters

      • needle: RegExp

        The regular expression to match. Must include the y (sticky) flag.

      Returns undefined | RegExpExecArray | RegExpMatchArray

      The match result if successful; otherwise, undefined.

    • Experimental

      Checks if the specified string matches the current position in the source without consuming it.

      Parameters

      • needle: string

        The string to match.

      • Optionalcomparer: EqualityComparer<any>

        An optional equality comparer for custom string comparison.

      Returns boolean

      true if the string matches; otherwise, false.