1987-03-10 11:49:39 +00:00
|
|
|
/* $Header$ */
|
1987-03-09 19:15:41 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1987-01-06 15:16:53 +00:00
|
|
|
/* EVALUATION OF BINARY OPERATORS */
|
|
|
|
|
|
|
|
#include "Lpars.h"
|
1987-08-19 10:36:37 +00:00
|
|
|
#include <em_arith.h>
|
1987-01-06 15:16:53 +00:00
|
|
|
|
|
|
|
ch7bin(pval, oper, val)
|
1987-08-19 10:36:37 +00:00
|
|
|
register arith *pval, val;
|
1987-01-06 15:16:53 +00:00
|
|
|
int oper;
|
|
|
|
{
|
|
|
|
switch (oper) {
|
|
|
|
case '%':
|
|
|
|
if (val == 0)
|
1989-11-01 10:02:23 +00:00
|
|
|
error("%% by 0");
|
1987-01-06 15:16:53 +00:00
|
|
|
else
|
|
|
|
*pval = *pval % val;
|
|
|
|
break;
|
|
|
|
case '/':
|
|
|
|
if (val == 0)
|
|
|
|
error("/ by 0");
|
|
|
|
else
|
|
|
|
*pval = *pval / val;
|
|
|
|
break;
|
|
|
|
case '*':
|
|
|
|
*pval = *pval * val;
|
|
|
|
break;
|
|
|
|
case '+':
|
|
|
|
*pval = *pval + val;
|
|
|
|
break;
|
|
|
|
case '-':
|
|
|
|
*pval = *pval - val;
|
|
|
|
break;
|
|
|
|
case LEFT:
|
|
|
|
*pval = *pval << val;
|
|
|
|
break;
|
|
|
|
case RIGHT:
|
|
|
|
*pval = *pval >> val;
|
|
|
|
break;
|
|
|
|
case '<':
|
|
|
|
*pval = (*pval < val);
|
|
|
|
break;
|
|
|
|
case '>':
|
|
|
|
*pval = (*pval > val);
|
|
|
|
break;
|
|
|
|
case LESSEQ:
|
|
|
|
*pval = (*pval <= val);
|
|
|
|
break;
|
|
|
|
case GREATEREQ:
|
|
|
|
*pval = (*pval >= val);
|
|
|
|
break;
|
|
|
|
case EQUAL:
|
|
|
|
*pval = (*pval == val);
|
|
|
|
break;
|
|
|
|
case NOTEQUAL:
|
|
|
|
*pval = (*pval != val);
|
|
|
|
break;
|
|
|
|
case '&':
|
|
|
|
*pval = *pval & val;
|
|
|
|
break;
|
|
|
|
case '^':
|
|
|
|
*pval = *pval ^ val;
|
|
|
|
break;
|
|
|
|
case '|':
|
|
|
|
*pval = *pval | val;
|
|
|
|
break;
|
|
|
|
case AND:
|
|
|
|
*pval = (*pval && val);
|
|
|
|
break;
|
|
|
|
case OR:
|
|
|
|
*pval = (*pval || val);
|
|
|
|
break;
|
|
|
|
case ',':
|
|
|
|
*pval = val;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|