compiler design
play

Compiler Design July 2004 Page 1 of 100 S. Arun-Kumar Go Back - PowerPoint PPT Presentation

Home Page Title Page CS432F/CSL 728: Compiler Design July 2004 Page 1 of 100 S. Arun-Kumar Go Back sak@cse.iitd.ernet.in Department of Computer Science and Engineering Full Screen I. I. T. Delhi, Hauz Khas, New


  1. CFG: Empty word Home Page G = �{ S } , { a, b } , P, S � , where S − → SS | aSb | ε Title Page generates all sequences of matching nested parentheses, including the empty word ε . ◭◭ ◮◮ A leftmost derivation might look like this: ◭ ◮ S ⇒ SS ⇒ SSS ⇒ SS ⇒ aSbS ⇒ abS ⇒ abaSb . . . Page 22 of 100 A rightmost derivation might look like this: Go Back S ⇒ SS ⇒ SSS ⇒ SS ⇒ SaSb ⇒ Sab ⇒ aSbab . . . Other derivations might look like God alone knows what! Full Screen S ⇒ SS ⇒ SSS ⇒ SS ⇒ . . . Close Could be quite confusing! Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  2. Home Page CFG: Derivation trees 1 Title Page ◭◭ ◮◮ Derivation sequences • put an artificial order in which productions are fired. ◭ ◮ • instead look at trees of derivations in which we may think of productions as being fired in parallel . Page 23 of 100 • There is then no highlighting in red to determine which Go Back copy of a nonterminal was used to get the next member of the sequence. Full Screen • Of course, generation of the empty word ε must be shown explicitly in the tree. Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  3. CFG: Derivation trees 2 Home Page Title Page S ◭◭ ◮◮ S S ◭ ◮ ε S S ε Page 24 of 100 Go Back a S b a S b Derivation tree of Full Screen ε a S b abaabb Close ε Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  4. CFG: Derivation trees 3 Home Page Title Page S ◭◭ ◮◮ S S ◭ ◮ S S a S b Page 25 of 100 Go Back a b ε S a b S Full Screen ε ε Another Close Derivation tree of abaabb Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  5. CFG: Derivation trees 4 Home Page Title Page S ◭◭ ◮◮ S S ◭ ◮ S S a S b Page 26 of 100 ε Go Back a b S a S b Full Screen ε ε Yet another Derivation tree of Close abaabb Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  6. Home Page Title Page ◭◭ ◮◮ ◭ ◮ Page 27 of 100 Go Back Full Screen Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  7. Ambiguity: 1 Home Page E → I | C | E + E | E ∗ E I → y | z Title Page C → 4 Consider the sentence y + 4 ∗ z . ◭◭ ◮◮ ◭ ◮ E E Page 28 of 100 Go Back Full Screen Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  8. Ambiguity: 2 Home Page E → I | C | E + E | E ∗ E I → y | z Title Page C → 4 Consider the sentence y + 4 ∗ z . ◭◭ ◮◮ ◭ ◮ E E Page 29 of 100 E E + * E E Go Back Full Screen Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  9. Ambiguity: 3 Home Page E → I | C | E + E | E ∗ E I → y | z Title Page C → 4 Consider the sentence y + 4 ∗ z . ◭◭ ◮◮ ◭ ◮ E E Page 30 of 100 E E + * E E Go Back E * + E E I E I Full Screen Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  10. Ambiguity: 4 Home Page E → I | C | E + E | E ∗ E I → y | z Title Page C → 4 Consider the sentence y + 4 ∗ z . ◭◭ ◮◮ ◭ ◮ E E Page 31 of 100 E E + * E E Go Back E * + E E I E I Full Screen I I C C y z Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  11. Ambiguity: 5 Home Page E → I | C | E + E | E ∗ E I → y | z Title Page C → 4 Consider the sentence y + 4 ∗ z . ◭◭ ◮◮ ◭ ◮ E E Page 32 of 100 E E + * E E Go Back E * + E E I E I Full Screen I I C C y z Close z y 4 Quit 4 • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  12. Home Page Title Page ◭◭ ◮◮ ◭ ◮ Page 33 of 100 Go Back Full Screen Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  13. Parsing: 0 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( ) E ◭ ◮ a − a / b Page 34 of 100 Go Back Full Screen Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  14. Parsing: 1 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( ) E ◭ ◮ − a / b Page 35 of 100 Principle: Go Back Reduce whenever possible. Shift only when Full Screen reduce is impossible Close a Shift Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  15. Parsing: 2 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( ) E ◭ ◮ − a / b Page 36 of 100 Go Back Full Screen Close Reduce by r5 D Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  16. Parsing: 3 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( ) E ◭ ◮ − a / b Page 37 of 100 Go Back Full Screen Close Reduce by r4 T Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  17. Parsing: 4 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( ) E ◭ ◮ − a / b Page 38 of 100 Go Back Full Screen Close Reduce by r2 E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  18. Parsing: 5 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ a / b Page 39 of 100 Go Back Full Screen Close Shift − E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  19. Parsing: 6 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ / b Page 40 of 100 Go Back Full Screen a Shift Close − E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  20. Parsing: 7 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ / b Page 41 of 100 Go Back Full Screen Reduce by r5 D Close − E E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  21. Parsing: 8 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ / b Page 42 of 100 Go Back Full Screen Reduce by r4 T Close − E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  22. Parsing: 8a Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ / b Page 43 of 100 Go Back Full Screen Reduce by r4 T Close − E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  23. Parsing: 9a Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ / b Page 44 of 100 Go Back Full Screen Close Reduce by r1 E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  24. Parsing: 10a Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ b Page 45 of 100 Go Back Full Screen Close / Shift E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  25. Parsing: 11a Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 46 of 100 Go Back Full Screen Shift b Close / E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  26. Parsing: 12a Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 47 of 100 Go Back Full Screen Reduce by r5 D Close / E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  27. Parsing: 13a Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 48 of 100 Go Back Full Screen T Reduce by r4 Close / E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  28. Parsing: 14a Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 49 of 100 Go Back ! k c Full Screen u t S Reduce by r2 E Close / Get back! E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  29. Parsing: 14b Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 50 of 100 Go Back Full Screen Reduce by r2 E Close / Get back! E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  30. Parsing: 13b Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 51 of 100 Go Back Full Screen T Reduce by r4 Close / Get back! E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  31. Parsing: 12b Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 52 of 100 Go Back Full Screen Reduce by r5 D Close / Get back! E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  32. Parsing: 11b Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 53 of 100 Go Back Full Screen Shift b Get back! Close / E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  33. Parsing: 10b Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ b Page 54 of 100 Go Back Full Screen Close / Shift Get back! E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  34. Parsing: 9b Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ / b Page 55 of 100 Go Back Full Screen Get back to where you Close once belonged! Reduce by r1 E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  35. Parsing: 8b d e Home Page i f i d o m − r1. E E T Principle: r2 E T Title Page Reduce whenever possible, but r3 T / D T but depending upon ◭◭ ◮◮ r4 T D lookahead r5 D a | b | ( E ) ◭ ◮ / b Page 56 of 100 Shift instead of reduce here! Go Back Shift−reduce conflict Full Screen Reduce by r4 T Close − E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  36. Parsing: 8 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ / b Page 57 of 100 Go Back Full Screen Reduce by r4 T Close − E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  37. Parsing: 9 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ b Page 58 of 100 Go Back Full Screen Shift / T Close − E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  38. Parsing: 10 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 59 of 100 Go Back b Shift Full Screen / T Close − E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  39. Parsing: 11 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 60 of 100 Go Back Reduce by r5 D Full Screen / T Close − E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  40. Parsing: 12 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 61 of 100 Go Back Full Screen Reduce by r3 T Close − E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  41. Parsing: 13 Home Page − r1. E E T r2 E T Title Page r3 T / D T ◭◭ ◮◮ r4 T D r5 D a | b | ( E ) ◭ ◮ Page 62 of 100 Go Back Full Screen Close Reduce by r1 E Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  42. Parse Trees: 0 Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 63 of 100 Go Back Full Screen Close a − a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  43. Parse Trees: 1 Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 64 of 100 Go Back Full Screen D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  44. Parse Trees: 2 Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 65 of 100 Go Back T Full Screen D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  45. Parse Trees: 3 Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 66 of 100 E Go Back T Full Screen D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  46. Parse Trees: 3a Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 67 of 100 E Go Back T Full Screen D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  47. Parse Trees: 3b Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 68 of 100 E Go Back T Full Screen D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  48. Parse Trees: 4 Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 69 of 100 E Go Back T Full Screen D D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  49. Parse Trees: 5 Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 70 of 100 E Go Back T T Full Screen D D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  50. Parse Trees: 5a Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 71 of 100 E Go Back T T Full Screen D D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  51. Parse Trees: 5b Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 72 of 100 E Go Back T T Full Screen D D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  52. Parse Trees: 6 Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 73 of 100 E Go Back T T Full Screen D D D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  53. Parse Trees: 7 Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ Page 74 of 100 E T Go Back T T Full Screen D D D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  54. Parse Trees: 8 Home Page − Title Page r1. E E T r4 T D r2 E T r5 D a | b | ( ) E r3 T / D T ◭◭ ◮◮ ◭ ◮ E Page 75 of 100 E T Go Back T T Full Screen D D D Close − a a / b Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  55. Home Page Parsing: Summary: 1 Title Page • All high-level languages are designed so that they may ◭◭ ◮◮ be parsed in this fashion with only a single token look- ahead. ◭ ◮ • Parsers for a language can be automatically con- structed by parger-generators such as Yacc, Bison, ML- Page 76 of 100 Yacc. • Shift-reduce conflicts if any, are automatically detected Go Back and reported by the parser-generator. Full Screen • Shift-reduce conflicts may be avoided by suitably redesigning the context-free grammar. Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  56. Home Page Parsing: Summary: 2 Title Page • Very often shift-reduce conflicts may occur because of the prefix problem. In such cases many parser- ◭◭ ◮◮ generators resolve the conflict in favour of shifting. ◭ ◮ • There is also a possiblility of reduce-reduce conflicts. This usually happens when there is more than one non- Page 77 of 100 terminal symbol to which the contents of the stack may reduce. Go Back • A minor reworking of the grammar to avoid redundant non-terminal symbols will get rid of reduce-reduce con- Full Screen flicts. The Big Picture Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  57. Semantic Analysis: 1 Home Page • Every Programming langauge can be used to program Title Page any computable function, assuming of course, it has – unbounded memory, and ◭◭ ◮◮ – unbounded time ◭ ◮ • The parser of a programming language provides the framework within which the target code is to be gener- ated. Page 78 of 100 • The parser also provides a structuring mechanism that Go Back divides the task of code generation into bits and pieces determined by the individual nonterminals and produc- Full Screen tion rules. • However, contex-free grammars are not powerful Close enough to represent all computable functions. Exam- ple, the language { a n b n c n | n > 0 } . Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  58. Home Page Semantic Analysis: 2 Title Page ◭◭ ◮◮ • There are context-sensitive aspects of a program that cannot be represented/enforced by a context-free gram- ◭ ◮ mar definition. Examples include – correspondence between formal and actual param- Page 79 of 100 eters – type consistency between declaration and use. Go Back – scope and visibility issues with respect to identifiers Full Screen in a program. Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  59. Home Page Title Page ◭◭ ◮◮ ◭ ◮ Page 80 of 100 Go Back Full Screen Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  60. Synthesized Attributes: 0 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T F / Page 81 of 100 n F Go Back ( ) E E T Full Screen − T F Close F n Quit n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  61. Synthesized Attributes: 1 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T F / Page 82 of 100 n F Go Back ( ) E E T Full Screen Synthesized Attributes − 4 3 2 1 T F Close F n Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  62. Synthesized Attributes: 2 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T F / Page 83 of 100 n F Go Back ( ) E E T Full Screen Synthesized Attributes − 4 3 2 1 T F Close F 4 n Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  63. Synthesized Attributes: 3 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T F / Page 84 of 100 n F Go Back ( ) E E T Full Screen Synthesized Attributes − 4 3 2 1 T 4 F Close F 4 n Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  64. Synthesized Attributes: 4 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T F / Page 85 of 100 n F Go Back ( ) E E 4 T Full Screen Synthesized Attributes − 4 3 2 1 T 4 F Close F 4 n Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  65. Synthesized Attributes: 5 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T F / Page 86 of 100 n F Go Back ( ) E E 4 T Full Screen Synthesized Attributes − 4 3 2 1 T 4 F Close F 4 n 1 Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  66. Synthesized Attributes: 6 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T F / Page 87 of 100 n F Go Back ( ) E E 4 T Full Screen Synthesized Attributes − 4 3 2 1 T 4 F 1 Close F 4 n 1 Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  67. Synthesized Attributes: 7 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T F / Page 88 of 100 n F Go Back ( ) E E 4 T Full Screen 1 Synthesized Attributes − 4 3 2 1 T 4 F 1 Close F 4 n 1 Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  68. Synthesized Attributes: 8 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T F / Page 89 of 100 n F Go Back ( ) 3 E E 4 T Full Screen 1 Synthesized Attributes − 4 3 2 1 T 4 F 1 Close F 4 n 1 Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  69. Synthesized Attributes: 9 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T F / Page 90 of 100 n 3 F Go Back ( ) 3 E E 4 T Full Screen 1 Synthesized Attributes − 4 3 2 1 T 4 F 1 Close F 4 n 1 Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  70. Synthesized Attributes: 10 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T 3 F / Page 91 of 100 n 3 F Go Back ( ) 3 E E 4 T Full Screen 1 Synthesized Attributes − 4 3 2 1 T 4 F 1 Close F 4 n 1 Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  71. Synthesized Attributes: 11 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T 3 F / Page 92 of 100 n 2 3 F Go Back ( ) 3 E E 4 T Full Screen 1 Synthesized Attributes − 4 3 2 1 T 4 F 1 Close F 4 n 1 Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  72. Synthesized Attributes: 12 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T − ◭ ◮ T 3 F 2 / Page 93 of 100 n 2 3 F Go Back ( ) 3 E E 4 T Full Screen 1 Synthesized Attributes − 4 3 2 1 T 4 F 1 Close F 4 n 1 Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  73. Synthesized Attributes: 13 Home Page Title Page T F E E ◭◭ ◮◮ ) ( / n T 1 − ◭ ◮ T 3 F 2 / Page 94 of 100 n 2 3 F Go Back ( ) 3 E E 4 T Full Screen 1 Synthesized Attributes − 4 3 2 1 T 4 F 1 Close F 4 n 1 Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  74. Synthesized Attributes: 14 Home Page Title Page T F E E 1 ◭◭ ◮◮ ) ( / n T 1 − ◭ ◮ T 3 F 2 / Page 95 of 100 n 2 3 F Go Back ( ) 3 E E 4 T Full Screen 1 Synthesized Attributes − 4 3 2 1 T 4 F 1 Close F 4 n 1 Quit 4 n • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  75. An Attribute Grammar Home Page Title Page E 0 → E 1 − T ⊲ E 0 .val := sub ( E 1 .val, T.val ) E 1 ◭◭ ◮◮ T 1 E → T ⊲ E.val := T.val T 3 F 2 ◭ ◮ / T 0 → T 1 /F ⊲ T 0 .val := div ( T 1 .val, F.val ) n 2 3 F Page 96 of 100 ( ) 3 E T → F ⊲ T.val := F.val E 4 T 1 − Go Back T 4 F 1 F → ( E ) ⊲ F.val := E.val Full Screen F 4 n 1 F → n ⊲ F.val := n .val 4 n Close Quit • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  76. Inherited Attributes: 0 C -style declarations generating int x , y , z . Home Page D → T L T → int | float L → L,I | I I → x | y | z Title Page D ◭◭ ◮◮ T L ◭ ◮ I , L int Page 97 of 100 z I Go Back L , y Full Screen I D L T I Close x y z int x Quit , • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  77. Inherited Attributes: 1 C -style declarations generating int x , y , z . Home Page D → T L T → int | float L → L,I | I I → x | y | z Title Page D ◭◭ ◮◮ T L ◭ ◮ I , L int int Page 98 of 100 z I Go Back L , y Full Screen I D L T I Close x y z int x Quit , int • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  78. Inherited Attributes: 2 C -style declarations generating int x , y , z . Home Page D → T L T → int | float L → L,I | I I → x | y | z Title Page D ◭◭ ◮◮ T L int ◭ ◮ I , L int int Page 99 of 100 z I Go Back L , y Full Screen I D L T I Close x y z int x Quit , int int • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

  79. Inherited Attributes: 3 C -style declarations generating int x , y , z . Home Page D → T L T → int | float L → L,I | I I → x | y | z Title Page D ◭◭ ◮◮ T L int int ◭ ◮ I , L int int Page 100 of 100 z I Go Back L , y Full Screen I D L T I Close x y z int x Quit , int int • First • Prev • Next • Last • Go Back • Full Screen • Close • Quit

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend