08-Top-Down-Parsing - 6/16/2009 CS 421 Lecture 8: Top-down...

Info iconThis preview shows pages 1–6. 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 DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: 6/16/2009 CS 421 Lecture 8: Top-down parsing s Lecture outline s Recursive-descent formalized s FIRST sets s LL(1) condition s Transformations to LL(1) form s Grammars for expressions 1 6/16/2009 Review: context-free grammar s Given: s Set of terminals (tokens) T s Set of non-terminals (variables) V s A cfg G is a set of p r o d u c t i o n s of the form s A X 1 X n ( n 0) where s A V , X 1 X n G = V T s One symbol designated as start symbol 2 6/16/2009 Top-down parsing: outline s Top-down parsing s Start parsing with start symbol s Apply production rules one by one s More than one production for rule A s Look at the next token to decide which production to apply 3 6/16/2009 Top-down parsing: pseudocode s For each non-terminal with productions s A X 1 X n | Y 1 Y n | | Z 1 Z n s Define parseA : parseA toklis = choose production based on hd toklis: if A X 1 X n : handle X 1 X n else if A Y 1 Y n : handle Y 1 Y n else if handle X 1 X n : handle X 1 ; handle X 2 ; ; handle X n where handle t : if hd toklis = t then remove t and continue else error handle B : parseB toklis 4 6/16/2009 choose production based on hd toklis s Need to formalize some things s Define s Derives in one step...
View Full Document

Page1 / 22

08-Top-Down-Parsing - 6/16/2009 CS 421 Lecture 8: Top-down...

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

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