Presentation is loading. Please wait.

Presentation is loading. Please wait.

Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. C H A P T E R T W O Syntax.

Similar presentations


Presentation on theme: "Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. C H A P T E R T W O Syntax."— Presentation transcript:

1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. C H A P T E R T W O Syntax

2 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-2 Parse Tree for 352 As an Integer Figure 2.1

3 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-3 A Program Fragment Viewed As a Stream of Tokens Figure 2.2

4 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-4 A Simple Lexical Syntax for a Small Language, Jay Figure 2.3

5 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-5 Major Stages in the Compiling Process Figure 2.4

6 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-6 Skeleton Lexical Analysis Method That Returns Tokens Figure 2.5

7 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-7 Conventions for Writing Regular Expressions Figure 2.6

8 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-8 A Concrete Syntax for Assignments and Expressions Figure 2.7

9 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-9 Parse Tree for the Expression x+2*y Figure 2.8

10 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-10 Sketch of a Parse Tree for a Complete Program Figure 2.9

11 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-11 Two Different Parse Trees for the AmbExp 2 – 3 – 4 Figure 2.10

12 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-12 An Ambiguous If Statement Figure 2.11

13 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-13 The “Dangling Else” Grammatical Ambiguity Figure 2.12

14 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-14 EBNF-Based Parse Tree for the Expression x+2*y Figure 2.13

15 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-15 Syntax Diagram for Expressions with Addition Figure 2.14

16 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-16 Abstract Syntax for Expression, Assignment, and Loop Figure 2.15

17 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-17 (a) Structure of a Binary Node. (b) Abstract Syntax Tree for the Expression x+2*y Figure 2.16

18 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-18 Partially Completed Recursive Descent Parse for Assignments Figure 2.17

19 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-19 Algorithm for Writing a Recursive Parser from EBNF Figure 2.18

20 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-20 An Example Jay Program to Compute the nth Fibonacci Number Figure 2.19

21 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 2-21 Sketch of the Abstract Syntax of a Jay WhileStatement Figure 2.20


Download ppt "Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. C H A P T E R T W O Syntax."

Similar presentations


Ads by Google