/** * edge-lexer * * (c) Edge * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Scan a string and seperate it into 2 pairs. The first pair will be series * of characters until the ending pattern is found and 2nd pair is the * left over. * * Their are some special behaviors over the regular `string.split` method. * * 1. Multiple lines can be passed by calling `scan` method for each line. * 2. Tolerates characters when they conflict with the ending pattern. * * ```js * const pattern = ')' * const tolerations = ['(', ')'] * const scanner = new Scanner(pattern, tolerations) * * scanner.scan('2 + 2 * (3))') * if (scanner.closed) { * scanner.match // 2 + 2 * (3) * scanner.leftOver // '' * } * ``` * * If we take the same string `2 + 2 * (3))` and split it using ')', then we * will get unexpected result, since the split method splits by finding the * first match. */ export declare class Scanner { #private; /** * Tracking if the scanner has been closed */ closed: boolean; /** * The matched content within the pattern */ match: string; /** * The content in the same line but after the closing * of the pattern */ leftOver: string; loc: { line: number; col: number; }; constructor(pattern: string, toleratePair: [string, string], line: number, col: number); /** * Scan a string and look for the closing pattern. The string will * be seperated with the closing pattern and also tracks the * toleration patterns to make sure they are not making the * scanner to end due to pattern mis-match. */ scan(chunk: string): void; }