/** Functions for working with constant values. */ import { Constant } from './types'; export declare enum ConstantType { SYMBOL = "Symbol",//: Symbol constants (e.g., :code:`(... :polarity -)`) STRING = "String",//: String constants (e.g., :code:`(... :op1 "Kim")`) INTEGER = "Integer",//: Integer constants (e.g., :code:`(... :value 12)`) FLOAT = "Float",//: Float constants (e.g., :code:`(... :value 1.2)`) NULL = "Null" } /** * Return the type of constant encoded by `constantString`. * * @param constantString - The string representation of the constant. * @returns The type of the constant. * @example * import { constantType } from 'penman-js'; * * console.log(constantType('-')); // Outputs: 'Symbol' * console.log(constantType('"foo"')); // Outputs: 'String' * console.log(constantType('1')); // Outputs: 'Integer' * console.log(constantType('1.2')); // Outputs: 'Float' * console.log(constantType('')); // Outputs: 'Null' */ export declare const constantType: (constant_string: string | null | undefined) => ConstantType; /** * Evaluate and return the value of `constantString`. * * If `constantString` is `null` or an empty symbol (`''`), this * function returns `null`. An empty string constant (`'""'`) returns an empty string (`''`). * Symbols are returned unchanged, while strings get quotes removed and escape sequences unescaped. * Note that this means it is impossible to recover the original type of * strings and symbols once they have been evaluated. For integer and * float constants, this function returns the equivalent JavaScript * `Number` object. * * @param constantString - The string representation of the constant. * @returns The evaluated value of the constant. * @example * import { evaluateConstant } from 'penman-js'; * * console.log(evaluateConstant('-')); // Outputs: '-' * console.log(evaluateConstant('"foo"')); // Outputs: 'foo' * console.log(evaluateConstant('1')); // Outputs: 1 * console.log(evaluateConstant('1.2')); // Outputs: 1.2 * console.log(evaluateConstant('') === null); // Outputs: true */ export declare const evaluateConstant: (constantString: string | null | undefined) => Constant; /** * Return `constant` as a quoted string. * * If `constant` is `null`, this function returns an empty string * constant (`'""'`). All other types are cast to a string and * quoted. * * @param constant - The value to quote. * @returns The quoted string representation of the constant. * @example * import { quoteConstant } from 'penman-js'; * * console.log(quoteConstant(null)); // Outputs: '""' * console.log(quoteConstant('')); // Outputs: '""' * console.log(quoteConstant('foo')); // Outputs: '"foo"' * console.log(quoteConstant('"foo"')); // Outputs: '"\\"foo\\""' * console.log(quoteConstant(1)); // Outputs: '"1"' * console.log(quoteConstant(1.5)); // Outputs: '"1.5"' */ export declare const quoteConstant: (constant: Constant) => string;