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

Info iconThis preview shows pages 1–7. 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 Lehigh University April 5, 2007
Background image of page 1

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

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE302: Compiler Design 04/05/07 Outline ± Recap ± Syntax-directed translation (Chapter 5) ± Intermediate-code generation ± Summary and homework
Background image of page 2
Instructor: Dr. Liang Cheng CSE302: Compiler Design 04/05/07 Syntax-directed Translation Schemes ± SDD SDT ± SDT’s can be implemented during parsing without building a parse tree ± S-attributed SDD based on LR-parsable grammar ± L-attributed SDD based on LL-parsable grammar
Background image of page 3

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

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE302: Compiler Design 04/05/07 An L-attributed SDD Example ± SDD of while to generate 3-address code ± S while ( C ) S ± while(i<a) i=i*2; j=j*i; ± label L5: if i<a goto L6 goto L7 label L6: i=i*2 goto L5 label L7: j=j*i ± while ( C ) S L1=new(); L2=new(); S1.next=L1; C.true=L2; C.false=S.next; S.code= label || L1 || C.code || label || L2 || S1.code
Background image of page 4
Instructor: Dr. Liang Cheng CSE302: Compiler Design 04/05/07 The Corresponding SDT ± For synthesized attribute computations ± End of the production body ± For computing inherited attributes of a nonterminal ± Immediately before the nonterminal occurrence S while ( { L1=new(); L2=new(); C.true=L2; C.false=S.next; } C) S1.next=L1; S1 { S.code= label || L1 || C.code || label || L2 || S1.code; }
Background image of page 5

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

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE302: Compiler Design 04/05/07 Recursive-descent Parser: One Function For Each Nonterminal S while ( { L1=new(); L2=new();
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 19

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

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online