cm-tarnation
Version:
An alternative parser for CodeMirror 6
45 lines (44 loc) • 1.71 kB
TypeScript
import type * as DF from "../definition";
import { Node } from "../node";
import type { Repository } from "../repository";
import type { GrammarState } from "../state";
import { Rule } from "./rule";
/**
* A sort of {@link Rule}-like object that affects a {@link GrammarStack}. It
* has `begin` and `end` properties which are {@link Rule}s that are used
* for switching states.
*/
export declare class State {
/** The name of this state. */
name: string;
/** The {@link Node} this state wraps tokens with. */
node: Node;
/** The {@link Rule} that starts this state. */
begin: Rule;
/** The {@link Rule} that ends this state. */
end: Rule;
/** The list of rules/states to loop parsing with when in this state. */
inside: (Rule | State)[] | Node | null;
/**
* If true, this state won't affect the stack, but instead manipulate the
* parser to "loosely" wrap tokens.
*/
loose?: boolean;
/**
* @param repo - The {@link Repository} to add this state to.
* @param state - The definition for this state.
*/
constructor(repo: Repository, state: DF.State);
/**
* @param state - The current {@link GrammarState}.
* @param str - The string to match.
* @param pos - The position to start matching at.
*/
match(state: GrammarState, str: string, pos: number): import("../matched").Matched | null;
/**
* @param state - The current {@link GrammarState}.
* @param str - The string to match.
* @param pos - The position to start matching at.
*/
close(state: GrammarState, str: string, pos: number): import("../matched").Matched | null;
}