PPT: Syntax Directed Translation Notes | EduRev

Compiler Design

Computer Science Engineering (CSE) : PPT: Syntax Directed Translation Notes | EduRev

 Page 1


Syntax Directed Translation
Page 2


Syntax Directed Translation
Outline
? Syntax Directed Definitions
? Evaluation Orders of SDD’s
? Applications of Syntax Directed Translation
? Syntax Directed Translation Schemes
Page 3


Syntax Directed Translation
Outline
? Syntax Directed Definitions
? Evaluation Orders of SDD’s
? Applications of Syntax Directed Translation
? Syntax Directed Translation Schemes
Introduction
? We can associate information with a language
construct by attaching attributes to the grammar
symbols.
? A syntax directed definition specifies the values of
attributes by associating semantic rules with the
grammar productions.
Production
Semantic Rule
E->E1+T
E.code=E1.code||T.code||’+’
 We may alternatively insert the semantic actions inside the grammar
E -> E1+T {print ‘+’}
Page 4


Syntax Directed Translation
Outline
? Syntax Directed Definitions
? Evaluation Orders of SDD’s
? Applications of Syntax Directed Translation
? Syntax Directed Translation Schemes
Introduction
? We can associate information with a language
construct by attaching attributes to the grammar
symbols.
? A syntax directed definition specifies the values of
attributes by associating semantic rules with the
grammar productions.
Production
Semantic Rule
E->E1+T
E.code=E1.code||T.code||’+’
 We may alternatively insert the semantic actions inside the grammar
E -> E1+T {print ‘+’}
Syntax Directed Definitions
? A SDD is a context free grammar with attributes and
rules
? Attributes are associated with grammar symbols and
rules with productions
? Attributes may be of many kinds: numbers, types,
table references, strings, etc.
? Synthesized attributes
? A synthesized attribute at node N is defined only in
terms of attribute values of children of N and at N it
? Inherited attributes
? An inherited attribute at node N is defined only in terms
of attribute values at N’s parent, N itself and N’s siblings
Page 5


Syntax Directed Translation
Outline
? Syntax Directed Definitions
? Evaluation Orders of SDD’s
? Applications of Syntax Directed Translation
? Syntax Directed Translation Schemes
Introduction
? We can associate information with a language
construct by attaching attributes to the grammar
symbols.
? A syntax directed definition specifies the values of
attributes by associating semantic rules with the
grammar productions.
Production
Semantic Rule
E->E1+T
E.code=E1.code||T.code||’+’
 We may alternatively insert the semantic actions inside the grammar
E -> E1+T {print ‘+’}
Syntax Directed Definitions
? A SDD is a context free grammar with attributes and
rules
? Attributes are associated with grammar symbols and
rules with productions
? Attributes may be of many kinds: numbers, types,
table references, strings, etc.
? Synthesized attributes
? A synthesized attribute at node N is defined only in
terms of attribute values of children of N and at N it
? Inherited attributes
? An inherited attribute at node N is defined only in terms
of attribute values at N’s parent, N itself and N’s siblings
Example of S-attributed SDD
1) L -> E n
2) E -> E1 + T
3) E -> T
4) T -> T1 * F
5) T -> F
6) F -> (E)
7) F -> digit
Production Semantic Rules
L.val = E.val
E.val = E1.val + T.val
E.val = T.val
T.val = T1.val * F.val
T.val = F.val
F.val = E.val
F.val = digit.lexval
Read More
Offer running on EduRev: Apply code STAYHOME200 to get INR 200 off on our premium plan EduRev Infinity!

Related Searches

ppt

,

Extra Questions

,

PPT: Syntax Directed Translation Notes | EduRev

,

Sample Paper

,

video lectures

,

Exam

,

PPT: Syntax Directed Translation Notes | EduRev

,

Objective type Questions

,

Important questions

,

mock tests for examination

,

shortcuts and tricks

,

PPT: Syntax Directed Translation Notes | EduRev

,

MCQs

,

practice quizzes

,

past year papers

,

study material

,

Previous Year Questions with Solutions

,

Semester Notes

,

Summary

,

Free

,

Viva Questions

,

pdf

;