expr.c 806 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* OPERATOR HANDLING */
  7. #include "Lpars.h"
  8. int
  9. rank_of(oper)
  10. int oper;
  11. {
  12. /* The rank of the operator oper is returned.
  13. */
  14. switch (oper) {
  15. default:
  16. return 0;
  17. case '(':
  18. return 1;
  19. case '!':
  20. return 2;
  21. case '*':
  22. case '/':
  23. case '%':
  24. return 3;
  25. case '+':
  26. case '-':
  27. return 4;
  28. case LEFT:
  29. case RIGHT:
  30. return 5;
  31. case '<':
  32. case '>':
  33. case LESSEQ:
  34. case GREATEREQ:
  35. return 6;
  36. case EQUAL:
  37. case NOTEQUAL:
  38. return 7;
  39. case '&':
  40. return 8;
  41. case '^':
  42. return 9;
  43. case '|':
  44. return 10;
  45. case AND:
  46. return 11;
  47. case OR:
  48. return 12;
  49. case '?':
  50. case ':':
  51. return 13;
  52. case ',':
  53. return 15;
  54. }
  55. /*NOTREACHED*/
  56. }