250 likes | 328 Views
Understand the bottom-up parsing process of a PDA for CFG productions with basic math operators. Slide show details the evaluation of the equation (3 + 4) * 5.
E N D
Bottom up parsing of a PDA for context free grammar Productions: P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 This is a nondeterministic PDA that is uses basic math operators. We will check the equation (3 + 4) * 5 to determine if it is part of the language. * This presentation is best viewed in a slide show. All writing in red corresponds to other red writing on the slide (mostly used to show transitions).
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack Z0 The stack Is empty
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack ( Z0 ( is pushed onto the stack
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack 3 ( Z0 3 is pushed onto the stack
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack A ( Z0 3 is popped from the stack and A is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack F ( Z0 A is popped from the stack and F is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack T ( Z0 F is popped from the stack and T is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack E ( Z0 T is popped from the stack and E is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack + E ( Z0 + is pushed onto the stack
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack 4 + E ( Z0 4 is pushed onto the stack
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack A + E ( Z0 4 is popped from the stack and A is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack F + E ( Z0 A is popped from the stack and F is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack T + E ( Z0 F is popped from the stack and T is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack E ( Z0 T, +, E are popped from the stack and E is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack ) E ( Z0 ) is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack F Z0 ( E ) are popped from the stack and F is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack T Z0 F is popped from the stack and T is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack * T Z0 * is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack 5 * T Z0 5 is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack A * T Z0 5 is popped and A is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack F * T Z0 A is popped and F is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack T Z0 F*T is popped and T is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack E Z0 T is popped and E is pushed
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 Stack Z0 E is popped, Leaving zo on The stack and The process is complete
Bottom up processing of (3+4)*5 P = E T | E + T T F | T * F F A | (E) A 0 | 1 | 2 |…|9 E T F T * F A ) ( E 5 E + T T F F A A 4 3 This is the complete tree that we just parsed from the bottom up.