tree-sitter - v0.25.1
    Preparing search index...

    Class Parser

    Index

    Constructors

    Methods

    • Get the ranges of text that the parser will include when parsing.

      Returns Range[]

      An array of ranges that will be included in parsing

    • Get the duration in microseconds that parsing is allowed to take.

      This timeout can be set via Parser.setTimeoutMicros.

      Returns number

      The parsing timeout in microseconds

      Use the progressCallback

    • Parse UTF8 text into a syntax tree.

      Parameters

      • input: string | Input

        The text to parse, either as a string or a custom input function that provides text chunks. If providing a function, it should return text chunks based on byte index and position.

      • OptionaloldTree: Tree

        An optional previous syntax tree from the same document. If provided and the document has changed, you must first edit this tree using Parser.Tree.edit to match the new text.

      • Optionaloptions: Options

        Optional parsing settings:

        • bufferSize: Size of internal parsing buffer
        • includedRanges: Array of ranges to parse within the input
        • progressCallback: A callback that receives the current parse state

      Returns Tree

      A syntax tree representing the parsed text

      May fail if no language has been set or parsing was halted.

    • Set the destination to which the parser should write debugging graphs during parsing.

      The graphs are formatted in the DOT language. You may want to pipe these graphs directly to a 'dot' process to generate SVG output.

      Parameters

      • Optionalenabled: boolean

        Whether to enable or disable graph output

      • Optionalfd: number

        Optional file descriptor for the output

      Returns void

    • Instruct the parser to start the next parse from the beginning.

      If the parser previously failed, it will resume where it left off on the next parse by default. Call this method if you want to parse a different document instead of resuming.

      Returns void

    • Set the language that the parser should use for parsing.

      The language must be compatible with the version of tree-sitter being used. A version mismatch will prevent the language from being assigned successfully.

      Parameters

      • Optionallanguage: Language

        The language to use for parsing

      Returns void

    • Set the logging callback that the parser should use during parsing.

      Parameters

      • OptionallogFunc: string | false | Logger

        The logging callback to use, or null/false to disable logging

      Returns void

    • Set the maximum duration that parsing is allowed to take before halting.

      If parsing takes longer than this, it will halt early, returning null.

      Parameters

      • timeout: number

        The maximum parsing duration in microseconds

      Returns void

      Use the progressCallback