{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

This preview shows pages 1–9. Sign up to view the full content.

CSE302: Compiler Design Instructor: Dr. Liang Cheng Department of Computer Science and Engineering P.C. Rossin College of Engineering & Applied Science Lehigh University February 22, 2007

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

View Full Document
Instructor: Dr. Liang Cheng CSE302: Compiler Design 02/22/07 Outline Recap Syntax analysis basics (Sections 4.1 & 4.2) Writing a grammar (Section 4.3) Top-down parsing (Section 4.4) Summary and homework
Instructor: Dr. Liang Cheng CSE302: Compiler Design 02/22/07 Input And Output Of Parsers A stream of tokens coming from lexer Generate some representation of the parse tree Collecting information about tokens into the symbol table Type checking and static semantic analysis Error handling

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

View Full Document
Instructor: Dr. Liang Cheng CSE302: Compiler Design 02/22/07 Notations for Context-free Grammar stmt if ( expr ) stmt else stmt Terminals Lowercase letters early in the alphabet ( a , b , c ) Operator symbols Punctuation symbols The digits 0,1,…,9 Boldface strings Nonterminals Uppercase letters early in the alphabet ( A , B , C,D,E,F ) & T E : expressions; T : terms; F : factors Letter S or the head of the 1 st production: start symbol Lowercase, italic names
Instructor: Dr. Liang Cheng CSE302: Compiler Design 02/22/07 More Notations for Context-free Grammar Uppercase letters late in the alphabet ( X , Y , Z ) represent grammar symbols Either nonterminals or terminals Lowercase Greek letters ( α , β , γ ,…) represent strings of grammar symbols A α Lowercase letter late in the alphabet ( u , v , w , x , y , z ) represent strings of terminals A set of productions A α 1 , A α 2 , … , A α k , with a common head A, may be written as A α 1 | α 2 | … | α k

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

View Full Document
Instructor: Dr. Liang Cheng CSE302: Compiler Design 02/22/07 Some Terminologies * If S means “derives in zero or more steps” * program a = b + const + The symbol means “derives in one or more steps”
Instructor: Dr. Liang Cheng CSE302: Compiler Design 02/22/07 BNF vs. Regular Expressions Every construct that can be described by a regular expression can be described by a BNF grammar A regular expression may not be able to define a language that can be defined by a BNF

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

View Full Document
Instructor: Dr. Liang Cheng
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}