O'Reilly logo

Express Learning: Principles of Compiler Design by ITL Education Solutions Limited

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

6

Syntax-directed Translations

1. What is syntax-directed translation? Explain.

Ans: Syntax-directed translation (SDT) is an extension of context-free grammar (CFG) which acts as a notational framework for the generation of intermediate code. It embeds program fragments (called semantic actions) within the production bodies. For example, as in

A → A1 * B {print ‘*’}

In SDT, by convention, we use curly braces to enclose semantic actions. If the grammar symbols contain curly braces, then we enclose them in single quotes as ‘{’ and ‘}’. The order of execution of semantic actions is determined by the position of a semantic action in a production body. Here, in the above example, the action occurs at the end, that is, after all the grammar symbols. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required