operators.js 768 B

1234567891011121314151617181920212223242526272829303132333435
  1. export const Operators = Object.freeze({
  2. ADD: 0,
  3. SUB: 1,
  4. MULT: 2,
  5. DIV: 3,
  6. MOD: 4,
  7. GT: 5,
  8. GE: 6,
  9. LT: 7,
  10. LE: 8,
  11. EQ: 9,
  12. NEQ: 10,
  13. AND: 11,
  14. OR: 12,
  15. NOT: 13
  16. });
  17. export function convertFromString (op) {
  18. switch (op) {
  19. case '+' : return Operators.ADD;
  20. case '-' : return Operators.SUB;
  21. case '*' : return Operators.MULT;
  22. case '/' : return Operators.DIV;
  23. case '%' : return Operators.MOD;
  24. case '>' : return Operators.GT;
  25. case '>=' : return Operators.GE;
  26. case '<' : return Operators.LT;
  27. case '<=' : return Operators.LE;
  28. case '==' : return Operators.EQ;
  29. case '!=' : return Operators.NEQ;
  30. case 'and' : return Operators.AND;
  31. case 'or' : return Operators.OR;
  32. case 'not' : return Operators.NOT;
  33. }
  34. }