210 likes | 301 Views
C H A P T E R T W O. Syntax. Parse Tree for 352 As an Integer Figure 2.1. A Program Fragment Viewed As a Stream of Tokens Figure 2.2. A Simple Lexical Syntax for a Small Language, Jay Figure 2.3. Major Stages in the Compiling Process Figure 2.4.
E N D
C H A P T E R T W O Syntax
Parse Tree for 352 As an Integer Figure 2.1
A Simple Lexical Syntax for a Small Language, Jay Figure 2.3
Major Stages in the Compiling Process Figure 2.4
Skeleton Lexical Analysis Method That Returns Tokens Figure 2.5
Conventions for Writing Regular Expressions Figure 2.6
A Concrete Syntax for Assignments and Expressions Figure 2.7
Parse Tree for the Expression x+2*y Figure 2.8
Two Different Parse Trees for the AmbExp 2 – 3 – 4 Figure 2.10
An Ambiguous If Statement Figure 2.11
The “Dangling Else” Grammatical Ambiguity Figure 2.12
EBNF-Based Parse Tree for the Expression x+2*y Figure 2.13
Syntax Diagram for Expressions with Addition Figure 2.14
Abstract Syntax for Expression, Assignment, and Loop Figure 2.15
(a) Structure of a Binary Node. (b) Abstract Syntax Tree for the Expression x+2*y Figure 2.16
Partially Completed Recursive Descent Parse for Assignments Figure 2.17
Algorithm for Writing a Recursive Parser from EBNF Figure 2.18
An Example Jay Program to Compute the nth Fibonacci Number Figure 2.19
Sketch of the Abstract Syntax of a Jay WhileStatement Figure 2.20