Syntax Directed Translation

Syntax Directed Translation

  • The Principle of Syntax Directed Translation states that the meaning of an input sentence is related to its syntactic structure, i.e., to its Parse-Tree.
  • By Syntax Directed Translations we indicate those formalisms for specifying translations for programming language constructs guided by context-free grammars.
    • We associate attributes to the grammar symbols representing the language constructs.
    • Values for attributes are computed by semantic rules associated with grammar productions.
    • In the semantic rule, attribute is VAL and an attribute may hold anything like a string, a number, a memory location and a complex record.
 Syntax Directed Translation

Syntax Directed Translation

  • Evaluation of Semantic Rules may:
    • Generate code ,
    • Insert information into the symbol table ,
    • Perform semantic check ,
    • Issue error messages.
  • There are two notations for attaching semantic rules:
    • Syntax Directed Definitions - High-level specification hiding many implementation details (also called Attribute Grammars).
    • Translation Schemes - More implementation oriented: Indicate the order in which semantic rules are to be evaluated.
 Notations for Semantic Rules

Notations for Semantic Rules


Production Semantic rule
E → E + T E.val := E.val + T.val
E → T E.val := T.val
T → T * F T.val := T.val + F.val
T → F T.val := F.val
F → (F) F.val := F.val
F → num F.val := num.lexval

E.val is one of the attributes of E.
num.lexval is the attribute returned by the lexical analyzer.

Related Searches to Syntax Directed Translation

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add to your ad blocking whitelist or disable your adblocking software.