{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Ml variable bindings ml does two bindings just

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: +c a+b+c UW CSE 401 (Michael Ringenburg) 29 “Something Useful” CSE341: Programmingthe traversal, perform •  At each point (CSE341: Programming Languages node) in Languages some semanQc acQon Lecture 1 Lecture 1 Course Course of full parse Mechanics –  Construct nodes Mechanics tree (rare) ML Variable Bindings ML Variable Bindings –  Construct abstract syntax tree (AST) (common) –  Construct linear, lower- level representaQon (ogen Dan Grossman D produced by tan Grossman raversing iniQal allST in opQmizaQon F A 2011 Fall 2011 phases of producQon compilers) –  Generate target code on the fly (used in 1- pass compiler; not common in producQon compilers) •  Can’t generate great code in one pass, – but useful if you need a quick ‘n dirty working compiler Winter 2013 UW CSE 401 (Michael Ringenburg) 30 Specifying Grammar CSE341: Programming Languages •  Why not just uCSE341: Programming Languages se a Regular Expression? –  Can’t express recture 1 structure – t1 creaQng an RE L ecursive Lecture ry for balanced parenthesis Course Course Mechanics Mechanics •  () just does one. ML Variable Bindings •  (()) ML does two. Bindings just Variable •  (*)* - Doesn’t guarantee balance. Dan Grossman Dan Grossman •  Need something like parens = Fparens), but this is recursive ( all 2011 and thus not a regular expression. Fall 2011 –  Fundamental problem: REs can’t “count” arbitrarily. –  Makes sense – DFAs (which can encode any RE) can’t count either, because they only have finite states, and no memory (beyond state). Winter 2013 UW CSE 401 (Michael Ringenburg) 31 Context- free Grammars CSE341: Programming •  CSE341: Programming Languagesre typically So instead, programming languages a Languages specified via a context- free Lecture 1 (CFG) grammar Lecture 1 –  CFGs can be recognized ourse Mechanics C by push down automata, which Course Mechanics are essenQally FAs plus a stack (makes counQng possible) ML Variable Bindings ML Variable Bindings •  Context- free grammars are a sweet...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online