IncrementalLatexParser class

Incremental LaTeX Parser (tree-sitter style)

Core design refers to tree-sitter's incremental parsing 3-tier strategy:

Tier 1: Incremental Tokenization (Token Reuse)

When an edit occurs, IncrementalTokenizer only re-tokenizes the affected region. Unmodified tokens before and after are directly reused (with offset shifting), avoiding full-text re-tokenization.

Tier 2: AST Subtree Reuse

Through TreeReuser, the top-level child nodes of the old AST are partitioned into three segments:

  • prefix: Before the edit region, kept directly
  • dirty: Overlaps with the edit region, re-parsed using new tokens
  • suffix: After the edit region, reused after offset shifting

Tier 3: Fault-tolerant Parsing

For incomplete inputs (e.g., streaming typing), uses intelligent truncation instead of brute-force backtracking: If full parsing fails, it truncates at structural boundaries ({}, $, \[...\], \begin..\end) to the nearest safe point.

Constructors

IncrementalLatexParser()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

append(String text) → void
Appends new LaTeX content (fast path)
clear() → void
Clears all content and state
getCurrentDocument() → DocumentNode
Gets the currently parseable document
getCurrentInput() → String
Gets the full content of the current buffer
getProgress() → double
Gets parsing progress (successfully parsed characters / total characters)
getUnparsedContent() → String
Gets the unparsed portion (for debugging or displaying)
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setInput(String newText) → void
Completely replaces the input content
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

tag → const String