Exemplo n.º 1
0
void Parser::ExprTail(ExprRec& result) {
	ExprRec leftOperand, rightOperand;
	OpRec op;
	switch (NextToken()) {
	case PLUS_OP:
	case MINUS_OP:
		leftOperand.kind = result.kind;
		leftOperand.ival = result.ival; /* Only allowed for */
		leftOperand.s_fval = result.s_fval; /* INTs and FLOATs  */
		leftOperand.name = result.name;
		leftOperand.var_type = result.var_type;
		AddOp();
		code.ProcessOp(op); /*** CODE ***/
		Factor(rightOperand);
		 /*** CODE ***/
		code.GenInfix(leftOperand, op, rightOperand, result);
		ExprTail(result);
		break;
	case RSTAPLE:
	case RBANANA:
	case RMUSTACHE:
	case SEMICOLON:
	case COMMA:
	case LT_OP:
	case LE_OP:
	case GT_OP:
	case GE_OP:
	case EQ_OP1:
	case EQ_OP2:
	case NE_OP:
		break;
	default:
		SyntaxError(NextToken(), "Unknown ExpressionTail Symbol.");
	}
}
Exemplo n.º 2
0
void Parser::CondTail(OpRec& op, ExprRec& e) {
	switch (NextToken()) {
	case LT_OP:
	case LE_OP:
	case GT_OP:
	case GE_OP:
	case EQ_OP1:
	case EQ_OP2:
	case NE_OP:
		RelOp();
		code.ProcessOp(op);
		Expression(e);
		break;
	case RBANANA:
	case SEMICOLON:
		break;
	default:
		SyntaxError(NextToken(), "CondTail");
	}
}