Syntax-directed translation

Syntax-directed translation refers to a method of compiler implementation where the source language translation is completely driven by the parser. A common method of syntax-directed translation is translating a string into a sequence of actions by attaching one such action to each rule of a grammar.[1] Thus, parsing a string of the grammar produces a sequence of rule applications. SDT provides a simple way to attach semantics to any such syntax.

## Contents

* 1 Overview
* 2 Metacompilers
* 3 See also
* 4 References

## Overview

Syntax-directed translation fundamentally works by adding actions to the productions in a context-free grammar, resulting in a Syntax-Directed Definition (SDD).[2] Actions are steps or procedures that will be carried out when that production is used in a derivation. A grammar specification embedded with actions to be performed is called a syntax-directed translation scheme[1] (sometimes simply called a 'translation scheme'.)

Each symbol in the grammar can have an attribute, which is a value that is to be associated with the symbol. Common attributes could include a variable type, the value of an expression, etc. Given a symbol X, with an attribute t, that attribute is referred to as X.t

Thus, given actions and attributes, the grammar can be used for translating strings from its language by applying the actions and carrying information through each symbol's attribute.

## Metacompilers

Early metacompilers use the terms syntax-driven and syntax-directed translation in their descriptions. They have metaprogramming language features for outputting code.

See metacompiler, META II, and TREE-META.

## See also

* Attribute grammar

## References

1. ↑ 1.0 1.1 Gurari, Eitan M.. "Syntax-Directed Translation Schemes (SDTS's)". http://www.cse.ohio-state.edu/~gurari/course/cse756/cse756su33.xht.
2. ↑ Aho, Alfred V. Compilers: Principles, Techniques, & Tools. Boston: Pearson/Addison Wesley, 2007.

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Syntax-directed translation. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Syntax-directed_translation&oldid=71028"