import { DScalar } from "./d-scalar"; export declare const DScalarExpressionNodeType: { readonly OPEN: 0; readonly CLOSE: 1; readonly PARENSESIS: 2; readonly ADD_OR_PLUS: 3; readonly SUB_OR_MINUS: 4; readonly PLUS: 5; readonly MINUS: 6; readonly ADD: 7; readonly SUB: 8; readonly MUL: 9; readonly DIV: 10; readonly MIN: 11; readonly MAX: 12; readonly COMMA: 13; readonly PARENT: 14; readonly SELF: 15; readonly PADDING: 16; readonly CURRENT: 17; readonly NUMBER: 18; }; export type DScalarExpressionNodeType = (typeof DScalarExpressionNodeType)[keyof typeof DScalarExpressionNodeType]; export type DScalarExpressionNodeTypeOperator = typeof DScalarExpressionNodeType.SUB_OR_MINUS | typeof DScalarExpressionNodeType.ADD_OR_PLUS | typeof DScalarExpressionNodeType.SUB | typeof DScalarExpressionNodeType.ADD | typeof DScalarExpressionNodeType.MUL | typeof DScalarExpressionNodeType.DIV | typeof DScalarExpressionNodeType.OPEN | typeof DScalarExpressionNodeType.CLOSE | typeof DScalarExpressionNodeType.MIN | typeof DScalarExpressionNodeType.MAX | typeof DScalarExpressionNodeType.COMMA; export type DScalarExpressionNodeTypeLiteral = typeof DScalarExpressionNodeType.NUMBER | typeof DScalarExpressionNodeType.PARENT | typeof DScalarExpressionNodeType.SELF | typeof DScalarExpressionNodeType.PADDING | typeof DScalarExpressionNodeType.CURRENT; export type DScalarExpressionToken = DScalarExpressionNodeTypeOperator | [DScalarExpressionNodeTypeLiteral, number]; export interface DScalarExpressionNodeOrTokenParensesis { [0]: typeof DScalarExpressionNodeType.PARENSESIS; [1]: DScalarExpressionNodeOrToken[]; } export interface DScalarExpressionNodeOrTokenUnary { [0]: typeof DScalarExpressionNodeType.PLUS | typeof DScalarExpressionNodeType.MINUS; [1]: DScalarExpressionNodeOrToken; } export type DScalarExpressionNodeArithmeticOperator = typeof DScalarExpressionNodeType.SUB | typeof DScalarExpressionNodeType.ADD | typeof DScalarExpressionNodeType.MUL | typeof DScalarExpressionNodeType.DIV; export interface DScalarExpressionNodeOrTokenArithmetic { [0]: DScalarExpressionNodeArithmeticOperator; [1]: DScalarExpressionNodeOrToken; [2]: DScalarExpressionNodeOrToken; } export interface DScalarExpressionNodeOrTokenFunction { [0]: typeof DScalarExpressionNodeType.MIN | typeof DScalarExpressionNodeType.MAX; [1]: DScalarExpressionNodeOrToken[]; } export type DScalarExpressionNodeOrToken = DScalarExpressionToken | DScalarExpressionNodeOrTokenParensesis | DScalarExpressionNodeOrTokenUnary | DScalarExpressionNodeOrTokenArithmetic | DScalarExpressionNodeOrTokenFunction; export interface DScalarExpressionNodeLiteral { [0]: DScalarExpressionNodeTypeLiteral; [1]: number; } export interface DScalarExpressionNodeParensesis { [0]: typeof DScalarExpressionNodeType.PARENSESIS; [1]: DScalarExpressionNode[]; } export interface DScalarExpressionNodeUnary { [0]: typeof DScalarExpressionNodeType.PLUS | typeof DScalarExpressionNodeType.MINUS; [1]: DScalarExpressionNode; } export interface DScalarExpressionNodeArithmetic { [0]: DScalarExpressionNodeArithmeticOperator; [1]: DScalarExpressionNode; [2]: DScalarExpressionNode; } export interface DScalarExpressionNodeFunction { [0]: typeof DScalarExpressionNodeType.MIN | typeof DScalarExpressionNodeType.MAX; [1]: DScalarExpressionNode[]; } export type DScalarExpressionNode = DScalarExpressionNodeParensesis | DScalarExpressionNodeUnary | DScalarExpressionNodeArithmetic | DScalarExpressionNodeFunction | DScalarExpressionNodeLiteral; /** * Parser and evaluator of the scalar expressions like `100% - 50s`. * * Literals * * * x%: 0.01 * x * parent value * * xs: 0.01 * x * self value * * xp: 0.01 * x * padding value * * xc: 0.01 * x * current value * * Operators * * * `+` * * `-` * * `*` * * `/` * * `(` and `)` * * Functions * * * min( a, b, ... ) * * max( a, b, ... ) * * Examples * * * `90%`: 0.9 * parent value * * `50s`: 0.5 * self value * * `90% - 50s`: 0.9 * parent value - 0.5 * self value * * `90% - (50s + 100) * 2`: 0.9 * parent value - ( 0.5 * self value + 100 ) * 2 */ export declare class DScalarExpression implements DScalar { protected static TOKEN_REGEX: RegExp; protected _node: DScalarExpressionNode; constructor(expression: string); toParensesis(nodes: DScalarExpressionNodeOrToken[], ifrom: number): number; toCommaOf(nodes: DScalarExpressionNodeOrToken[], ifrom: number, ito: number): DScalarExpressionNodeOrToken; toComma(nodes: DScalarExpressionNodeOrToken[], ifrom: number, ito: number): DScalarExpressionNodeOrToken[]; toUnaryNode(node: DScalarExpressionNodeOrToken): void; toUnary(nodes: DScalarExpressionNodeOrToken[]): void; toArithmeticNode(node: DScalarExpressionNodeOrToken, operatorA: DScalarExpressionNodeArithmeticOperator, operatorB: DScalarExpressionNodeArithmeticOperator): void; toArithmetic(nodes: DScalarExpressionNodeOrToken[], operatorA: DScalarExpressionNodeArithmeticOperator, operatorB: DScalarExpressionNodeArithmeticOperator): void; toToken(expression: string): DScalarExpressionToken[]; toTokenOperator(token: string): DScalarExpressionNodeTypeOperator | null; toTokenLiteral(token: string): DScalarExpressionNodeTypeLiteral | null; protected evaluate(node: DScalarExpressionNode, parent: number, self: number, padding: number, current: number): number; calculate(parent: number, self: number, padding: number, current: number): number; }