import { LazyPattern, PatternFound } from "./lazyPattern"; /** * A basic rule to catch a pattern. */ export interface BasicRule { /** * Name of the rule. */ name?: string; /** * Default value of the rule in case something wrong happen. */ defaultValue?: any; /** * The string that begin the charbox. */ begin?: string; /** * The string that end the charbox. */ end?: string; /** * Function predicate to know when a pattern start. */ isPattern: (i: number, c: string, t: string) => boolean; /** * Function predicate to know when a pattern end. */ isPatternEnd?: (i: number, c: string, t: string) => boolean; /** * A function to handle */ fetch?: (i: number, c: string, t: string, isPatternEnd?: (i: number, c: string, t: string) => boolean, patternSet?: LazyPattern[]) => PatternFound; } /** * A generic rule maker. It creates rules for LazyParsing. */ export declare class LazyRule { /** * A basic pattern to extract a specific character. * @param {string} name Name of the pattern. * @param {(c:string) => boolean} predicate The function to test the character. * @returns {BasicRule} Return a rule. */ static simpleChar(name: string, predicate: (c: string) => boolean): BasicRule; /** * A basic pattern to extract a specific string. * @param {string} name Name of the pattern. * @param {string} extractString The function to test the string. * @returns {BasicRule} Return a rule. */ static simpleKeys(name: string, ...extractStrings: string[]): BasicRule; /** * A basic charbox that will contain the nested in-between string content. * @param {string} name The name of the charbox. * @param {string} begin The string that begin the charbox. * @param {string} end The string that end the charbox. * @param {LazyPattern[] | undefined} overridePatternSet An override to use new rules inside the charbox. * @param {(i: number, c: string, txt: string) => boolean | undefined} overrideIsPatternEnd An override to use a new end pattern to handle special cases. * @returns {BasicRule} Return a rule. */ static simpleCharbox(name: string, begin: string, end: string, overridePatternSet?: LazyPattern[], overrideIsPatternEnd?: (i: number, c: string, txt: string) => boolean): BasicRule; /** * A basic rule to extract words. Words can only be made with letters. * @returns {BasicRule} Return a rule. */ static word(): BasicRule; /** * A basic rule to extract numbers. The number can only be written in the form `125` or either `1.2123` if `comaOverDot = false` otherwise `1,2123`. * @param {boolean} comaOverDot If true, numbers must be written as "x,y" instead of "x.y". * @returns {BasicRule} Return a rule. */ static number(comaOverDot?: boolean, exp?: boolean): BasicRule; /** * A basic rule to extract a variable name. The variable name must be composed of only letters and underscores. * @returns {BasicRule} Return a rule. */ static variable(): BasicRule; /** * A basic rule to extract keywords. They must begin by a letter or an underscore and can only contains letters or underscores. * @param {string[]} keywordList A list of keywords. * @returns {BasicRule} Return a rule. */ static keyword(...keywordList: string[]): BasicRule; /** * A basic pattern to extract any character without exception. * @param {string} name Name of the rule. * @returns {BasicRule} Return a rule. */ static any(name: string): BasicRule; /** * A basic pattern to extract a string like syntax. It will work the same as c/c++/c#/js/java/... string. So whatever is your `between` value, if it's "\\myStringValue", it will be escaped. * @param {string} name Name of the rule. * @param {string} between The string container. If between = '"', then it will parse a string the same way js does. * @returns {BasicRule} Return a rule. */ static parseString(name: string, between: string): BasicRule; /** * A basic pattern rule to test a regex. Note: when you write your regex, think like you're at the start of the string for the test. * @param {string} name Name of the rule. * @param {RegExp} regex The regex * @returns {BasicRule} Return a rule. */ static regex(name: string, regex: RegExp): BasicRule; } //# sourceMappingURL=lazyRule.d.ts.map