/**
 * Syntax classification from the engine's own tree-sitter parse (CG-57).
 *
 * The viewer used to run a second highlighter (Shiki + 56 pruned TextMate
 * grammars) over source the engine had already parsed with a real grammar. This
 * takes the classification off the tree instead, which removes the second
 * dependency, the second grammar set, and — the part that actually mattered —
 * the second opinion: a `.ts` file is now read by exactly the grammar that
 * decided what its symbols are.
 *
 * ## What comes out
 *
 * A flat, ordered, non-overlapping list of {@link SyntaxSpan}s over the source
 * string. Gaps between spans are whitespace and are the caller's to fill. The
 * classes are deliberately few, because the design's code colouring is
 * near-monochrome: comments recede, strings and numbers recede one step less,
 * keywords carry weight rather than hue, and the only colour in the body is a
 * call site the graph resolved.
 *
 * ## How a node becomes a class
 *
 * The rules are language-agnostic on purpose — the engine indexes 40-odd
 * languages and a per-grammar scope table would be 40 tables to keep true:
 *
 * * a node whose type mentions `comment` is a comment, whole, undescended;
 * * inside a string node every leaf is string, *except* below an interpolation,
 *   where the code starts again (so `${user.name()}` still links);
 * * a numeric literal node is a number;
 * * an **anonymous** leaf is a keyword when its text is a bare word and
 *   punctuation otherwise — this is what makes `func`, `fn`, `def`, `END-IF`
 *   and `Sub` all land as keywords without naming any of them;
 * * a **named** leaf whose text is identifier-shaped is an identifier, unless
 *   the grammar called it a type name, or the extractor's own definition tables
 *   say it is the name of a definition.
 *
 * The last of those is the one place per-language knowledge is used, and it is
 * reused rather than restated: {@link EXTRACTORS} already names every node type
 * that declares something in each language, plus the field its name hangs on.
 */
import type { Node as SyntaxNode } from 'web-tree-sitter';
import { Language } from '../types';
/**
 * Every class a token can carry, in wire order.
 *
 * `other` is punctuation and whitespace both. The design spec lists them apart
 * (`punct` vs the gaps) but they paint identically — plain ink — and splitting
 * them would roughly double the token count on a dense line to express a
 * difference nothing draws.
 */
export declare const SYNTAX_TOKEN_CLASSES: readonly ["other", "ident", "comment", "string", "keyword", "number", "type", "def"];
export type SyntaxTokenClass = (typeof SYNTAX_TOKEN_CLASSES)[number];
/** A classified run of the source, by JS string index. Half-open. */
export interface SyntaxSpan {
    start: number;
    end: number;
    cls: SyntaxTokenClass;
}
/**
 * Classify one parsed tree into spans.
 *
 * Exported for tests and for anything that already holds a tree; the usual
 * entry point is {@link tokenizeSource}, which parses first.
 */
export declare function classifyTree(root: SyntaxNode, source: string, language: Language, offset?: number): SyntaxSpan[];
/**
 * A stretch of a file written in a different language from the file itself.
 *
 * Single-file components are the only case: a `.svelte`, `.vue` or `.astro`
 * file has no tree-sitter grammar of its own here, but its `<script>` block —
 * where every symbol the engine indexed in that file lives — is ordinary
 * TypeScript or JavaScript. The extractors already delegate exactly this way,
 * so the viewer reads a component's code with the same grammar the graph was
 * built from. The surrounding markup stays unclassified, which under a
 * near-monochrome theme costs the recession on tag names and attribute strings
 * and nothing else.
 */
export interface SyntaxRegion {
    start: number;
    end: number;
    language: Language;
}
/**
 * The sub-language regions of a file, or null when the file is one language.
 *
 * Null and an empty array mean different things: null is "parse the whole file
 * as `language`", empty is "this file has a grammar for none of it".
 */
export declare function syntaxRegionsFor(source: string, language: Language): SyntaxRegion[] | null;
export interface TokenizeResult {
    spans: SyntaxSpan[];
    /** The grammar(s) that produced them, for the payload's `grammar` field. */
    grammars: string[];
}
/**
 * Parse `source` and classify it.
 *
 * Returns null when nothing in the file has a grammar — a plain answer, which
 * every caller here already knows how to serve. Never throws: a grammar that
 * fails to load or a parse that comes back empty is the same outcome as not
 * having one.
 */
export declare function tokenizeSource(source: string, language: Language): Promise<TokenizeResult | null>;
//# sourceMappingURL=syntax-tokens.d.ts.map