ch7bin.c 1.2 KB

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