{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Feb22 - CSE302 Compiler Design Instructor Dr Liang Cheng...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full Document Right Arrow Icon
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
Background image of page 2
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
Background image of page 3

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

View Full Document Right Arrow Icon
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
Background image of page 4
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
Background image of page 5

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

View Full Document Right Arrow Icon
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”
Background image of page 6
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
Background image of page 7

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

View Full Document Right Arrow Icon
Instructor: Dr. Liang Cheng
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}