parser.d.ts 1004 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. export interface MathExpression {
  2. type: 'MathExpression';
  3. right: CalcNode;
  4. left: CalcNode;
  5. operator: '*' | '+' | '-' | '/';
  6. }
  7. export interface ParenthesizedExpression {
  8. type: 'ParenthesizedExpression';
  9. content: CalcNode;
  10. }
  11. export interface DimensionExpression {
  12. type:
  13. | 'LengthValue'
  14. | 'AngleValue'
  15. | 'TimeValue'
  16. | 'FrequencyValue'
  17. | 'PercentageValue'
  18. | 'ResolutionValue'
  19. | 'EmValue'
  20. | 'ExValue'
  21. | 'ChValue'
  22. | 'RemValue'
  23. | 'VhValue'
  24. | 'VwValue'
  25. | 'VminValue'
  26. | 'VmaxValue';
  27. value: number;
  28. unit: string;
  29. }
  30. export interface NumberExpression {
  31. type: 'Number';
  32. value: number;
  33. }
  34. export interface FunctionExpression {
  35. type: 'Function';
  36. value: string;
  37. }
  38. export type ValueExpression = DimensionExpression | NumberExpression;
  39. export type CalcNode = MathExpression | ValueExpression | FunctionExpression | ParenthesizedExpression;
  40. export interface Parser {
  41. parse: (arg: string) => CalcNode;
  42. }
  43. export const parser: Parser;