/*
 * Production: Arithmetic Expression
 * FIRST set: { -, +, AVID_T, FPL_T, INL_T, ( }
 */
void arithmetic_expression(void) {
    switch (lookahead.code) {
        case ART_OP_T:
            /* The attribute must be MINUS or PLUS. */
            switch (lookahead.attribute.arr_op) {
                case MINUS:
                case PLUS:
                    unary_arithmetic_expression();
                    break;
                    
                default:
                    syn_printe();
                    return;
            }
            break;
        
        case AVID_T:
        case FPL_T:
        case INL_T:
        case LPR_T:
            additive_arithmetic_expression();
            break;
        
        /* If nothing matches, print an error. */
        default:
            syn_printe();
            return;
    }
    
    gen_incode("PLATY: Arithmetic expression parsed");
}
示例#2
0
/* FIRST(arithmetic expression)={-,+,AVID_T,FPL_T,INL_T,(}
<arithmetic expression> - >
	<unary arithmetic expression>
	| <additive arithmetic expression>
Author: Kwok Hong Kelvin Chan */
void arithmetic_expression(void){
	switch(lookahead_token.code){
	case AVID_T:
	case FPL_T:
	case INL_T:
	case LPR_T:
		additive_arithmetic_expression();
		gen_incode("Arithmetic expression parsed");
		break;
	case ART_OP_T:
		switch(lookahead_token.attribute.arr_op){
		case MINUS:
		case PLUS:	
			unary_arithmetic_expression();
			gen_incode("Arithmetic expression parsed");
			break;
		default:
			syn_printe();
			break;
		}
		break;
	default:
		syn_printe();
		break;
	}
}