import { JSONSchema7 } from 'json-schema'; import { JSONSchemaFormatOptions, CompactJSONFormat, P_MAIN } from './typings'; /** * Main Parser class, wraps nearley parser main methods. */ export declare class Parser { private compiledGrammar; private parser; private jsonSchemaFormatter; private compactFormatter; /** * Parsed statements. */ private statements; /** * Remains of string feed, after last parsed statement. */ private remains; /** * Whether preparser is currently escaped. */ private escaped; /** * Current quote char of preparser. */ private quoted; /** * Parser constructor. * Default dialect is 'mysql'. * * @param dialect SQL dialect ('mysql' or 'mariadb' currently supported). */ constructor(dialect?: 'mysql' | 'mariadb'); /** * Feed chunk of string into parser. * * @param chunk Chunk of string to be parsed. */ feed(chunk: string): Parser; /** * Recreates NearleyParser using grammar given in constructor. */ resetParser(): void; /** * Checks whether character is a quotation character. * * @param char Character to be evaluated. */ private static isQuoteChar; /** * Tidy parser results. * * @param results Parser results. */ private static tidy; /** * Parser results getter. Will run nearley parser on string fed to this parser. */ get results(): P_MAIN; /** * Formats given parsed JSON to a compact format. * If no JSON is given, will use currently parsed SQL. * * @param json Parsed JSON format. */ toCompactJson(json?: P_MAIN): CompactJSONFormat[]; /** * Formats parsed SQL to an array of JSON Schema documents, * where each item is the JSON Schema of a table. If no * tables are given, will use currently parsed SQL. * * @param tables Array of tables in compact JSON format. * @param options Options available to format as JSON Schema. */ toJsonSchemaArray(options?: JSONSchemaFormatOptions, tables?: CompactJSONFormat[]): JSONSchema7[]; }