Mechanics mechanics useful invariant when a parser

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: ming CSE341: Programming Languages Languages •  Main advantage of top- down parsing is that it is easy to implement by 1 and Lecture h Lecture 1 –  And automaVc LL generators may produce easier to Course Course Mechanics Mechanics follow/debug code. ML Variable Bindings ML Variable Bindings •  Key idea: write a funcVon (procedure, method) Dan Grossman corresponding to each non- terminal in the Dan Grossman Fall 2011 grammar Fall 2011 –  Each of these funcVons is responsible for matching its non- terminal with the next part of the input –  Recall this is top- down – so at each step we are looking at the lePmost non- terminal trying to figure out what to do. Winter 2013 UW CSE 401 (Michael Ringenburg) 21 Example: Statements CSE341: Programming CSE341: Programming Languages Languages •  Grammar Method f 1 Lecture 1 •  Lectureor this grammar rule stmt ::= id = exp ; // parse stmt ::= id=exp Course Mechanics ; | … Course Mechanics stmt( ) { | return exp ; void ML Variable Bindings | if ( eML sVariable Bindings nextToken) { xp ) tmt switch(...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online