UNPKG

swift-pattern-compiler

Version:

A compiler which transforms SWIFT patterns to an object representation with additional information's.

51 lines (50 loc) 1.36 kB
import { IAst, ISwiftObject } from "./interfaces"; /** * The object generator takes an ast object and returns a swift object. * * ``` * const ast { * type: "SwiftPattern", * body: [ * { * type: "line", * nodes: [ * { * type: "field", * length: { min: 0, max: 35 }, * char: "a" * }, * ] * } * ] * }; * objectGenerator(ast); * { * linesCount: 1, * lines: [ * { * minChars: 0, * maxChars: 35, * regExp: "[A-Z]{0,35}", * allowedCharsClass: "[A-Z]", * }, * ], * maxChars: 35, * regExp: "[A-Z]{0,35}", * allowedCharsClass: "[A-Z]", * } * ``` */ export declare const generator: (ast: IAst) => ISwiftObject; /** * Returns the char class for the passed char or an empty string * for an unsupported char. * @param char */ export declare const getCharClass: (char: string) => string; /** * Returns a quantifier string for the passed min, max values. * @param min * @param max */ export declare const getQuantifier: (min: number, max: number) => string;