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
    position: number = 0

    Current position in the source string.

    source: string

    The source string to be parsed.

    • get isEof(): boolean
      Experimental

      Indicates whether the parser has reached the end of the source string.

      Returns boolean

      true if the current position is at or beyond the end of the source; otherwise, false.

    • 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 string | undefined

      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 RegExpExecArray | RegExpMatchArray | undefined

      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 string | undefined

      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 RegExpExecArray | RegExpMatchArray | undefined

      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.