6.10 a. Draw dependency graphs corresponding to each grammar rule of Example 6.14 (page 283), and for the expression 5/2/2.0. b. Describe the two passes required to compute the attributes on the syntax tree of 5/2/2.0, including a possible order in which the nodes could be visited and the attribute values computed at each point.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Compile Technology Just do 6.10 And example 6.14 also given coz you will need this to complete 6.10.
6.10 a. Draw dependency graphs corresponding to each grammar rule of Example 6.14 (page
283), and for the expression 5/2/2.0.
b. Describe the two passes required to compute the attributes on the syntax tree of
5/2/2.0, including a possible order in which the nodes could be visited and the
attribute values computed at each point.
Transcribed Image Text:6.10 a. Draw dependency graphs corresponding to each grammar rule of Example 6.14 (page 283), and for the expression 5/2/2.0. b. Describe the two passes required to compute the attributes on the syntax tree of 5/2/2.0, including a possible order in which the nodes could be visited and the attribute values computed at each point.
Example 6.14
Consider the following simple version of an expression grammar:
еxp > ехp / ехp | num| num.num
This grammar has a single operation, division, indicated by the token 7. It also has two
versions of numbers: integer numbers consisting of sequences of digits, which we indi-
cate by the token num, and floating-point numbers, which we indicate by the token
num.num. The idea of this grammar is that operations may be interpreted differently,
depending on whether they are floating-point or strictly integer operations. Division, in
particular, is quite different, depending on whether fractions are allowed. If not, divi-
sion is often called a div operation, and the value of 5/4 is 5 div 4 = 1. If floating-
point division is meant, then 5/4 has value 1.2.
Suppose now that a programming language requires mixed expressions to be pro-
moted to floating-point expressions throughout, and the appropriate operations to be
used in their semantics. Thus, the meaning of the expression 5/2/2.0 (assuming left
Transcribed Image Text:Example 6.14 Consider the following simple version of an expression grammar: еxp > ехp / ехp | num| num.num This grammar has a single operation, division, indicated by the token 7. It also has two versions of numbers: integer numbers consisting of sequences of digits, which we indi- cate by the token num, and floating-point numbers, which we indicate by the token num.num. The idea of this grammar is that operations may be interpreted differently, depending on whether they are floating-point or strictly integer operations. Division, in particular, is quite different, depending on whether fractions are allowed. If not, divi- sion is often called a div operation, and the value of 5/4 is 5 div 4 = 1. If floating- point division is meant, then 5/4 has value 1.2. Suppose now that a programming language requires mixed expressions to be pro- moted to floating-point expressions throughout, and the appropriate operations to be used in their semantics. Thus, the meaning of the expression 5/2/2.0 (assuming left
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY