b) What is the associativity of the % operator? a) left b) right c) neither c) What is the associativity of the & operator? a) left b) right c) neither 1

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Consider the following BNF grammar (G1) for simple assignment statements.
Assign = Id "=" Expr.
Id= "a" | "b" | "c".
Expr
=
Expr"_ Expr.
| Expr "/" Expr.
Id.
Give an unambiguous grammar G2 that is equivalent to G1.
Consider the alphabet Σ = {a, b, c, %, &} and let G be the following grammar, where S is the
start symbol.
E → a
E → b
E→C
S→T%S
S→T
T→ T&E
T→ E
a) Draw a parse tree for a%b&c.
b) What is the associativity of the % operator?
a) left
b) right
c) neither
c) What is the associativity of the & operator?
a) left
b) right
c) neither
1
Transcribed Image Text:Consider the following BNF grammar (G1) for simple assignment statements. Assign = Id "=" Expr. Id= "a" | "b" | "c". Expr = Expr"_ Expr. | Expr "/" Expr. Id. Give an unambiguous grammar G2 that is equivalent to G1. Consider the alphabet Σ = {a, b, c, %, &} and let G be the following grammar, where S is the start symbol. E → a E → b E→C S→T%S S→T T→ T&E T→ E a) Draw a parse tree for a%b&c. b) What is the associativity of the % operator? a) left b) right c) neither c) What is the associativity of the & operator? a) left b) right c) neither 1
Expert Solution
Step 1: Answer B)

b) Associativity of the % Operator:
In the grammar G:
S - > T% * S | T
Here, the % operator is utilized in the creation T% * S. The associativity of an operator decides the request wherein activities of a similar priority are performed.

Left-Associativity: Assuming an operator is left-associative, it implies that tasks are performed from left to right. For instance, in the articulation a%b%c, it is identical to (a%b)%c. The % operator is applied to an and b first, and afterward the outcome is utilized with c.

Right-Associativity: Assuming an operator is right-associative, it implies that tasks are performed from right to left. For instance, in the articulation a^b^c,, it is identical to a^(b^c). The ^ operator is applied to b and c first, and afterwards the outcome is utilized with a.

The right solution for the given grammar is a) left, showing that the % operator is left-associative.

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Concept of memory addresses in pointers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education