SYNTAX DIRECTED
TRANSLATION (SDT)
PREPARED BY: GAURAV JANMARE
ROLL NO :37
SUBJECT :COMPILER CONSTRUCTOR
INTRODUCTION TO SYNTAX
DIRECTED TRANSLATION
• Syntax Directed Translation (SDT) is a method
used in compilers for translating programming
languages.
• It associates attributes with grammar symbols
and semantic rules to define how translation is
performed.
• SDT is useful in syntax analysis and code
generation.
SYNTAX DIRECTED
DEFINITIONS (SDD)
• SDD consists of:
- A context-free grammar.
- Attributes associated with grammar symbols.
- Semantic rules that define attribute
computation.
• Attributes can be synthesized or inherited.
TYPES OF SDT
1. S-Attributed SDT:
- Uses only synthesized attributes.
- Evaluated in a bottom-up manner.
2. L-Attributed SDT:
- Uses both inherited and synthesized
attributes.
- Evaluated in a left-to-right order.
EXAMPLE OF SDT
Example Grammar:
E → E1 + T { E.val = E1.val + T.val }
T → T1 * F { T.val = T1.val * F.val }
The rules compute attribute values during
parsing.
APPLICATIONS OF SDT
• Used in compilers for semantic analysis.
• Helps in syntax tree generation and
intermediate code generation.
• Used in attribute grammars for language
translation.
CONCLUSION
• Syntax Directed Translation helps in processing
language syntax and semantics together.
• It plays a crucial role in compiler design for
efficient translation.
• Understanding SDT is essential for building
better language processors.