1 / 14

SYNTAX DIRECTED TRANSLATION

SYNTAX DIRECTED TRANSLATION. COMPILERS 29 TH OCTOBER 2013. SDD. Semantic Rule. A.x = f ( X 1 .a, X 2 .b, X 3 .c ). A  X 1 X 2 X 3. SDT. Embedded. A  X 1 X 2 { A.x = f( X 1 .a, X 2 .b) } X 3. S – attributed SDD SDT A  X 1 X 2 X 3 {a}

gracie
Download Presentation

SYNTAX DIRECTED TRANSLATION

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SYNTAX DIRECTED TRANSLATION COMPILERS29TH OCTOBER 2013

  2. SDD Semantic Rule A.x = f ( X1.a, X2.b, X3.c ) A  X1X2X3

  3. SDT Embedded A  X1X2{A.x = f( X1.a, X2.b) }X3

  4. S – attributed SDD SDT A  X1X2X3 {a} When we perform reduction, we evaluate the attribute to get the result

  5. We have the stackX1X2X3  symbols and statesX1.a, X2.b, X3.c  values

  6. After ReductionA  replaces X1X2X3A.x evaluated by the functionf( X1.a, X2.b, X3.c )

  7. L  E { Print (E.val) }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  id { F.val = id }

  8. To evaluate T.val = T.val * F.val , we need the two values; which we get form the value stack.

  9. L – attributed SDD is suitable for top-down parsing LL (1) synthesized attributes inherited attributes

  10. A non-terminal can have multiple inherited attributes ; for each will have some defined action In case of synthesize attribute, we append it to the end of the ruleFor predictive parsers, for each non-terminal, we have a function

  11. E.G : Recursive Descent ParserA  X1X2X3A() { if ( a == X1 ) move to next symbolif ( X1 is a NT) X1() }

  12. This function invokes the functions of the body of the productionTo implement predictive parsing, we need to implement those functions

  13. Made By : Mohit Bhura11CS30019

More Related