Winter 2013 uw cse 401 michael ringenburg 13 parsing

Info iconThis preview shows page 1. Sign up to view the full content.

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: Parsing CSE341: Programming Languages CSE341: Programming G and a sentence w in •  Parsing: Given a grammar Languages L(G ), traverse the derivaQon ecture 1ree) for w in Lecture 1 L (parse t Course Course Mechanics Mechanics some standard order and do something useful at ML Variable Bindings M each node L Variable Bindings –  The parse tree might not be Dan Grossman produced explicitly, but the Dan Grossman control flow of the parser corresponds to a traversal Fall 2011 Fall 2011 –  For example, can generate the AST directly based on this traversal, without ever actually building the intermediate parse tree. Winter 2013 UW CSE 401 (Michael Ringenburg) 13 Parsing CSE341: Programming Languages CSE341: Programming •  For efficiency we want Languages to avoid the parser backtracking Lecture make a wrong guess). (don’t 1 Lecture 1 Course Mechanics –  Can be Cone if you allow parser to “lookahead”, d ourse Mechanics ML Variable Bindings ML Variable Bindings and specify the grammar properly. –  Keeps Qme Dinear in the size of source code. l an Grossman Dan Grossman •  Also want to eFall 2011 the source program xamine Fall 2011 from le9 to right. –  Parse the program in the order tokens are returned from the scanner. Winter 2013 UW CSE 401 (Michael Ringenburg) 14 Common Orderings CSE341: Programming CSE341: •  Top- down Programming Languages Languages Lecture 1 –  Start with the Loot (start symbol of grammar G) r ecture 1 Course –  Traverse the parse tree depth- first, leg- to- right Course Mechanics Mechanics MderivaQon parse tree (expanding –  Equivalent to a legmost L Variable Bindings ML Variable Bindings the legmost nonterminal at every step). –  LL(k) par...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online