PPT: Syntax Directed Translation | Compiler Design - Computer Science Engineering (CSE) PDF Download

Download, print and study this document offline
Please wait while the PDF view is loading
 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
26 videos|66 docs|30 tests

Top Courses for Computer Science Engineering (CSE)

FAQs on PPT: Syntax Directed Translation - Compiler Design - Computer Science Engineering (CSE)

1. What is syntax-directed translation in computer science engineering?
Ans. Syntax-directed translation is a technique used in computer science engineering to perform translation of source code from one language to another. It involves associating translation rules with the productions of a grammar to guide the translation process.
2. How does syntax-directed translation work?
Ans. Syntax-directed translation works by associating semantic actions with the productions of a grammar. These semantic actions define the translation rules and specify the actions to be performed during the translation process. As the source code is parsed and the grammar productions are applied, the associated translation rules are executed to generate the corresponding target code.
3. What are the benefits of syntax-directed translation?
Ans. Syntax-directed translation offers several benefits in computer science engineering. It helps automate the process of code translation, reducing the effort required for manual translation. It also ensures consistency and accuracy in the translation process by following predefined translation rules. Additionally, it allows for the generation of optimized target code by incorporating optimization techniques within the translation rules.
4. Can syntax-directed translation handle complex source code?
Ans. Yes, syntax-directed translation can handle complex source code. It is designed to handle grammars of programming languages, which often have complex syntax structures. By associating translation rules with the grammar productions, syntax-directed translation can effectively handle the complexity and generate the corresponding target code.
5. Are there any limitations to syntax-directed translation?
Ans. While syntax-directed translation is a powerful technique, it does have some limitations. It heavily relies on the accuracy of the grammar and the associated translation rules. If the grammar is incomplete or the translation rules are not properly defined, it can lead to incorrect translations. Additionally, syntax-directed translation may not be suitable for languages with ambiguous or highly dynamic syntax structures, as it requires unambiguous grammar productions for effective translation.
26 videos|66 docs|30 tests
Download as PDF
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev
Related Searches

past year papers

,

study material

,

PPT: Syntax Directed Translation | Compiler Design - Computer Science Engineering (CSE)

,

Viva Questions

,

PPT: Syntax Directed Translation | Compiler Design - Computer Science Engineering (CSE)

,

practice quizzes

,

Extra Questions

,

video lectures

,

ppt

,

shortcuts and tricks

,

MCQs

,

Summary

,

Previous Year Questions with Solutions

,

Important questions

,

Free

,

Sample Paper

,

mock tests for examination

,

pdf

,

PPT: Syntax Directed Translation | Compiler Design - Computer Science Engineering (CSE)

,

Objective type Questions

,

Semester Notes

,

Exam

;