SlideServe
Menu
Préférences
© SlideServe · v2026

Chapter 2 A Simple Syntax-Directed Translator

elewa avatar
47 diapositives · 1K Views · Jul 17, 2014

Chapter 2 A Simple Syntax-Directed Translator. Figure 2.1: A code fragment to be translated. Figure 2.2: Simplified intermediate code for the program fragment in Fig. 2.1. Figure 2.3: A model of a compiler front end. Figure 2.4: Intermediate code for "do i = i + 1 ; while ( a [il < v) ; ".

Chapter 2 A Simple Syntax-Directed Translator - slide 1
01 / 47Chapter 2 A Simple Syntax-Directed Translator
1 / 17

Télécharger la présentation

Chapter 2 A Simple Syntax-Directed Translator
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Chapter 2A Simple Syntax-Directed Translator

  2. Figure 2.1: A code fragment to be translated

  3. Figure 2.2: Simplified intermediate code for the program fragment in Fig. 2.1

  4. Figure 2.3: A model of a compiler front end

  5. Figure 2.4: Intermediate code for "do i = i + 1 ; while ( a [il < v) ; "

  6. Figure 2.5: Parse tree for 9-5+2 according to the grammar in Example 2.1

  7. Figure 2.6: Two parse trees for 9-5+2

  8. Figure 2.7: Parse trees for left- and right-associative grammars

  9. Figure 2.8: A grammar for a subset of Java statements

  10. Figure 2.9: Attribute values at nodes in a parse tree

  11. Figure 2.10: Syntax-directed definition for infix to postfix translation

  12. Figure 2.11: A depth-first traversal of a tree

  13. Figure 2.12: Example of a depth-first traversal of a tree

  14. Figure 2.13: An extra leaf is constructed for a semantic action

  15. Figure 2.14: Actions translating 9-5+2 into 95-2+

  16. Figure 2.15: Actions for translating into postfix notation

  17. Figure 2.16: A grammar for some statements in C and Java

  18. Figure 2.17: A parse tree according to the grammar in Fig. 2.16

  19. Figure 2.18: Top-down parsing while scanning the input from left to right

  20. Figure 2.19: Pseudocode for a predictive parser

  21. Figure 2.20: Left- and right-recursive ways of generating a string

  22. Figure 2.21: Actions for translating into postfix notation

  23. Figure 2.22: Syntax tree for 9-5+2

  24. Figure 2.23: Translation scheme after left-recursion elimination

  25. Figure 2.24: Translation of 9-5+2 to 95-2+

  26. Figure 2.25: Pseudocode for non-terminals expr, rest, and term

  27. Figure 2.26: Eliminating tail recursion in the procedure rest of Fig. 2.25

  28. Figure 2.27: Java program to translate infix expressions into postfix form

  29. Figure 2.28: Actions for translating into postfix notation

  30. Figure 2.29: Skipping white space

  31. Figure 2.30: Grouping digits into integers

  32. Figure 2.31: Distinguishing keywords from identifiers

  33. Figure 2.32: Class Token and subclasses Nurn and Word

  34. Figure 2.33: Subclasses Num and Word of Token

  35. Figure 2.34: Code for a lexical analyzer, part 1 of 2

  36. Figure 2.35: Code for a lexical analyzer, part 2 of 2

  37. Figure 2.36: Chained symbol tables for Example 2.15

  38. Figure 2.37: Class Env implements chained symbol tables

  39. Figure 2.38: The use of symbol tables for translating a language with blocks

  40. Figure 2.39: Construction of syntax trees for expressions and statements

  41. Figure 2.40: Part of a syntax tree for a statement list consisting of an ifstatementand a while-statement

  42. Figure 2.41: Concrete and abstract syntax for several Java operators

  43. Figure 2.42: Code layout for if-statements

  44. Figure 2.43: Function gen in class If generates three-address code

  45. Figure 2.44: Pseudocode for function lualue

  46. Figure 2.45: Pseudocode for function rvalue

  47. Figure 2.46: Two possible translations of a statement