/* FIRST(unary arithmetic expression)={-,+} <unary arithmetic expression> -> - <primary arithmetic expression> | + <primary arithmetic expression> Author: Kyle Hinskens */ void unary_arithmetic_expression(void){ switch(lookahead_token.attribute.arr_op){ case MINUS: match(ART_OP_T,MINUS); primary_arithmetic_expression(); gen_incode("Unary arithmetic expression parsed"); break; case PLUS: match(ART_OP_T,PLUS); primary_arithmetic_expression(); gen_incode("Unary arithmetic expression parsed"); break; default: syn_printe(); break; } }
/* FIRST(multiplicative arithmetic expression’)={*,/,e} <multiplicative arithmetic expression’> -> * <primary arithmetic expression> <multiplicative arithmetic expression’> | / <primary arithmetic expression> <multiplicative arithmetic expression’> | e Author: Kyle Hinskens */ void multiplicative_arithmetic_expression_p(void){ switch(lookahead_token.code){ case ART_OP_T: switch(lookahead_token.attribute.arr_op){ case MULT: match(ART_OP_T,MULT); primary_arithmetic_expression(); multiplicative_arithmetic_expression_p(); gen_incode("Multiplicative arithmetic expression parsed"); break; case DIV: match(ART_OP_T,DIV); primary_arithmetic_expression(); multiplicative_arithmetic_expression_p(); gen_incode("Multiplicative arithmetic expression parsed"); break; } } }
/* FIRST(multiplicative arithmetic expression)={AVID_T, FPL_T,INL_T ,(} <multiplicative arithmetic expression> -> <primary arithmetic expression> <multiplicative arithmetic expression’> Author: Kwok Hong Kelvin Chan */ void multiplicative_arithmetic_expression(void){ switch(lookahead_token.code){ case AVID_T: case FPL_T: case INL_T: case LPR_T: primary_arithmetic_expression(); multiplicative_arithmetic_expression_p(); break; } }
/* * Production: Multiplicative Arithmetic Expression (P) * FIRST set: { *, /, e } */ void multiplicative_arithmetic_expression_p(void) { switch (lookahead.code) { case ART_OP_T: /* The token attribute mut be DIV or MULT. */ switch (lookahead.attribute.arr_op) { case DIV: case MULT: match(ART_OP_T, lookahead.attribute.arr_op); primary_arithmetic_expression(); multiplicative_arithmetic_expression_p(); gen_incode("PLATY: Multiplicative arithmetic expression parsed"); return; default: return; } return; default: return; } }
/* * Production: Unary Arithmetic Expression * FIRST set: { -, + } */ void unary_arithmetic_expression(void) { switch (lookahead.code) { case ART_OP_T: /* Arithmetic operator token */ /* The current token attribute must be MINUS or PLUS. */ switch (lookahead.attribute.arr_op) { case MINUS: case PLUS: match(lookahead.code, lookahead.attribute.arr_op); primary_arithmetic_expression(); gen_incode("PLATY: Unary arithmetic expression parsed"); return; /* If the token attribute is not MINUS or PLUS, print an error. */ default: syn_printe(); return; } /* If the token code is not ART_OP_T, print an error. */ default: syn_printe(); return; } }
/* * Production: Multiplicative Arithmetic Expression * FIRST set: { AVID_T, FPL_T, INL_T, ( } */ void multiplicative_arithmetic_expression(void) { primary_arithmetic_expression(); multiplicative_arithmetic_expression_p(); }