UNPKG

cm-tarnation

Version:

An alternative parser for CodeMirror 6

48 lines (47 loc) 1.72 kB
import type { Matcher, VariableTable } from "../../types"; /** * Matcher that takes in a list of strings, and matches each one against an * input to see if any match. */ export declare class LookupMatcher implements Matcher { /** True if matching is case-insensitive. */ private ignoreCase; /** A list of number arrays, each one being a codepoint representation of a word. */ private entries; /** A mapping between the `entries` list and lengths of their source word. */ private lengths; /** The longest entry in `entries`, by its original string length. */ private max; /** * @param src - The source list of strings. * @param ignoreCase - If `true`, matches will be case-insensitive. * @param variables - A variable table to use when expanding variables. */ constructor(src: string[], ignoreCase?: boolean, variables?: VariableTable); /** * Internal method which returns the length of a match against a string, * if one was found. * * @param str - The string to match. * @param pos - The position to start matching at. */ private exec; /** * Tests to see if a string is in this list. * * @param str - The string to match. * @param pos - The position to start matching at. */ test(str: string, pos: number): boolean; /** * Returns the results of attempting to match a string against this list. * * @param str - The string to match. * @param pos - The position to start matching at. */ match(str: string, pos: number): { total: string; captures: null; length: number; } | null; }