expr.c 799 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 rank_of(int oper)
  9. {
  10. /* The rank of the operator oper is returned.
  11. */
  12. switch (oper) {
  13. default:
  14. return 0;
  15. case '(':
  16. return 1;
  17. case '!':
  18. return 2;
  19. case '*':
  20. case '/':
  21. case '%':
  22. return 3;
  23. case '+':
  24. case '-':
  25. return 4;
  26. case LEFT:
  27. case RIGHT:
  28. return 5;
  29. case '<':
  30. case '>':
  31. case LESSEQ:
  32. case GREATEREQ:
  33. return 6;
  34. case EQUAL:
  35. case NOTEQUAL:
  36. return 7;
  37. case '&':
  38. return 8;
  39. case '^':
  40. return 9;
  41. case '|':
  42. return 10;
  43. case AND:
  44. return 11;
  45. case OR:
  46. return 12;
  47. case '?':
  48. case ':':
  49. return 13;
  50. case ',':
  51. return 15;
  52. }
  53. /*NOTREACHED*/
  54. }