Example #1
0
static NumValue term(int get) {
	NumValue left = prim (get);
	for (;;) {
		if (curr_tok == MUL) {
			left = Nmul (left, prim (1));
		} else
		if (curr_tok == DIV) {
			NumValue d = prim (1);
			if (!d.d) {
				error ("divide by 0");
				return d;
			}
			left = Ndiv (left, d);
		} else return left;
	}
}
Example #2
0
static RNumCalcValue term(RNum *num, RNumCalc *nc, int get) {
	RNumCalcValue left = prim (num, nc, get);
	for (;;) {
		if (nc->curr_tok == RNCMUL) {
			left = Nmul (left, prim (num, nc, 1));
		} else if (nc->curr_tok == RNCMOD) {
			RNumCalcValue d = prim (num, nc, 1);
			if (!d.d) {
				//error (num, nc, "divide by 0");
				return d;
			}
			left = Nmod (left, d);
		} else if (nc->curr_tok == RNCDIV) {
			RNumCalcValue d = prim (num, nc, 1);
			if (num != NULL && (!d.d || !d.n)) {
				num->dbz = 1;
				return d;
			}
			left = Ndiv (left, d);
		} else {
			return left;
		}
	}
}