Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I do not understand what is the meaning of B.twice , M1.ones,and M1.zeros. Question 6 (26 points) Consider the following CFG for binary numbers. B

I do not understand what is the meaning of B.twice , M1.ones,and M1.zeros.

image text in transcribed

Question 6 (26 points) Consider the following CFG for binary numbers. B Z + 2 B.twice = false + NM +0 + 1 + ZM + NM + E M M M (a) Augment this grammar with attribute rules that will accumulate true into a twice at- tribute of the root of the parse tree if the string contains at least twice as many ls as Os, and false otherwise. Solution: B + Z B. twice = false B + NM B.twice = M.ones+1 > M.zeros Z +0 N + 1 Mi + Z M2 Mi.zeros = M2.zeros + 1 M + N M2 > Mj.ones = M2.ones + 1 M + M.zeros = 0 M.ones = 0 (b) Is your attribute grammar S-attributed? Solution: Yes. Question 6 (26 points) Consider the following CFG for binary numbers. B Z + 2 B.twice = false + NM +0 + 1 + ZM + NM + E M M M (a) Augment this grammar with attribute rules that will accumulate true into a twice at- tribute of the root of the parse tree if the string contains at least twice as many ls as Os, and false otherwise. Solution: B + Z B. twice = false B + NM B.twice = M.ones+1 > M.zeros Z +0 N + 1 Mi + Z M2 Mi.zeros = M2.zeros + 1 M + N M2 > Mj.ones = M2.ones + 1 M + M.zeros = 0 M.ones = 0 (b) Is your attribute grammar S-attributed? Solution: Yes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions