ch7bin.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. /* EVALUATION OF BINARY OPERATORS */
  7. #include "Lpars.h"
  8. #include <em_arith.h>
  9. ch7bin(pval, oper, val)
  10. register arith *pval, val;
  11. int oper;
  12. {
  13. switch (oper) {
  14. case '%':
  15. if (val == 0)
  16. error("%% by 0");
  17. else
  18. *pval = *pval % val;
  19. break;
  20. case '/':
  21. if (val == 0)
  22. error("/ by 0");
  23. else
  24. *pval = *pval / val;
  25. break;
  26. case '*':
  27. *pval = *pval * val;
  28. break;
  29. case '+':
  30. *pval = *pval + val;
  31. break;
  32. case '-':
  33. *pval = *pval - val;
  34. break;
  35. case LEFT:
  36. *pval = *pval << val;
  37. break;
  38. case RIGHT:
  39. *pval = *pval >> val;
  40. break;
  41. case '<':
  42. *pval = (*pval < val);
  43. break;
  44. case '>':
  45. *pval = (*pval > val);
  46. break;
  47. case LESSEQ:
  48. *pval = (*pval <= val);
  49. break;
  50. case GREATEREQ:
  51. *pval = (*pval >= val);
  52. break;
  53. case EQUAL:
  54. *pval = (*pval == val);
  55. break;
  56. case NOTEQUAL:
  57. *pval = (*pval != val);
  58. break;
  59. case '&':
  60. *pval = *pval & val;
  61. break;
  62. case '^':
  63. *pval = *pval ^ val;
  64. break;
  65. case '|':
  66. *pval = *pval | val;
  67. break;
  68. case AND:
  69. *pval = (*pval && val);
  70. break;
  71. case OR:
  72. *pval = (*pval || val);
  73. break;
  74. case ',':
  75. *pval = val;
  76. break;
  77. }
  78. }