ll_parsing

ll_parsing - COP4020 Programming Languages Computing LL(1...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: COP4020 Programming Languages Computing LL(1) parsing table Prof. Xin Yuan COP4020 Spring 2011 2 02/20/12 Overview LL(1) parsing in action (Top-down parsing) Computing LL(1) parsing table Using the parsing table, the predictive parsing program works like this: A stack of grammar symbols ($ on the bottom) A string of input tokens ($ at the end) A parsing table, M[NT, T] of productions Algorithm: put ‘$ Start’ on the stack ($ is the end of input string). 1) if top == input == $ then accept 2) if top == input then pop top of the stack; advance to next input symbol; goto 1; 3) if top is nonterminal if M[top, input] is a production then replace top with the production; goto 1 else error 4) else error Example: (1) E->TE’ (2) E’->+TE’ (3) E’-> (4) T->FT’ (5) T’->*FT’ (6) T’-> (7) F->(E) (8) F->id id + * ( ) $ E (1) (1) E’ (2) (3) (3) T (4) (4) T’ (6) (5) (6) (6) F (8) (7) Stack input production $E id+id*id$ $E’T id+id*id$ E->TE’ $E’T’F id+id*id$ T->FT’ $E’T’id id+id*id$ F->id $E’T’ +id*id$ …......
View Full Document

{[ snackBarMessage ]}

Page1 / 11

ll_parsing - COP4020 Programming Languages Computing LL(1...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online