Example #1
0
/* FIRST(additive arithmetic expression’)={+,-, e}
<additive arithmetic expression’> ->
	+ <multiplicative arithmetic expression> <additive arithmetic expression’> 
	| - <multiplicative arithmetic expression> <additive arithmetic expression’> 
	| e
Author: Kyle Hinskens */
void additive_arithmetic_expression_p(void){
	switch(lookahead_token.code){
	case ART_OP_T:
		switch (lookahead_token.attribute.arr_op){
		case PLUS:
			match(ART_OP_T,PLUS);
			multiplicative_arithmetic_expression();
			additive_arithmetic_expression_p();
			gen_incode("Additive arithmetic expression parsed");
			break;
		case MINUS:
			match(ART_OP_T,MINUS);
			multiplicative_arithmetic_expression();
			additive_arithmetic_expression_p();
			gen_incode("Additive arithmetic expression parsed");
			break;
		}
		break;
	}
}
Example #2
0
/* FIRST(additive arithmetic expression)={AVID_T, FPL_T,INL_T ,(}
<additive arithmetic expression> ->  
	<multiplicative arithmetic expression> <additive arithmetic expression’>
Author: Kwok Hong Kelvin Chan */
void additive_arithmetic_expression(void){
	switch(lookahead_token.code){
		case AVID_T:
		case FPL_T:
		case INL_T:
		case LPR_T: 
			multiplicative_arithmetic_expression();
			additive_arithmetic_expression_p(); 
			break;
	}
}
/*
 * Production: Additive Arithmetic Expression (P)
 * FIRST set: { +, -, e }
 */
void additive_arithmetic_expression_p(void) {
    switch (lookahead.code) {
        case ART_OP_T:
            switch (lookahead.attribute.arr_op) {
                /* The attribute must be MINUS or PLUS. */
                case MINUS:
                case PLUS:
                    match(ART_OP_T, lookahead.attribute.arr_op);
                    multiplicative_arithmetic_expression();
                    additive_arithmetic_expression_p();
                    gen_incode("PLATY: Additive arithmetic expression parsed");
                    return;
                    
                default:
                    return;
            }
            return;
            
        default:
            return;
    }
}
/*
 * Production: Additive Arithmetic Expression
 * FIRST set: { AVID_T, FPL_T, INL_T, ( }
 */
void additive_arithmetic_expression(void) {
    multiplicative_arithmetic_expression();
    additive_arithmetic_expression_p();
}