Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Number Grammars Note that many of these grammars could be written as regular grammars, but here we'll practice writing them in standard Backus-Naur Form -

image text in transcribed
Number Grammars Note that many of these grammars could be written as regular grammars, but here we'll practice writing them in standard Backus-Naur Form - BNF (note: do not use Extended BNF). NUM1 = the set of all integers, including leading and optional leading '#' signs. Give parse trees for O and -128 NUM2 = the set of even negative integers (-2,-4,-6, ...). Give parse trees for -16, and -378. NUM3 = the set of signed decimal numbers, with at least one digit (possibly zero) both before and after the decimal point. Give parse trees for +1.2, and -33.03. Identifier Grammars ID1 = the set of strings beginning with an upper-case letter, followed by any number of lower case letters or digits. Give parse trees for Sumi and R. ID2 = the set of strings of letters, digits, underscores and dashes, provided that (1) the first character in the string is an upper-case letter, and (2) the final character is neither an underscore nor a dash. Give parse trees for BB-8 and case_1. ID3 = the set of strings axbx -- any number of a's followed by an equal number of b's. Give parse trees for the empty string (i.e. O a's and Ob's) and aabb. Boolean Expression Grammar Write a grammar for Boolean expressions might be simple literals like 3 or 97 or may be more complex syntactic units like (3+x)/4. They evaluate to a number. You needn't concern yourself with their structure; just that they can be used as below. Boolean expressions include the literals TRUE and FALSE; they can be combined with the unary operator ! (meaning NOT) and binary operators && and II (meaning AND and OR). Also, arithmetic expressions can be combined with the following binary operators to form new Boolean expressions: ,, !=. When your grammar is complete, you should be able to derive parse trees for expressions like the following: TRUE FALSE FALSE && !TRUE 27= TRUE FALSE Number Grammars Note that many of these grammars could be written as regular grammars, but here we'll practice writing them in standard Backus-Naur Form - BNF (note: do not use Extended BNF). NUM1 = the set of all integers, including leading and optional leading '#' signs. Give parse trees for O and -128 NUM2 = the set of even negative integers (-2,-4,-6, ...). Give parse trees for -16, and -378. NUM3 = the set of signed decimal numbers, with at least one digit (possibly zero) both before and after the decimal point. Give parse trees for +1.2, and -33.03. Identifier Grammars ID1 = the set of strings beginning with an upper-case letter, followed by any number of lower case letters or digits. Give parse trees for Sumi and R. ID2 = the set of strings of letters, digits, underscores and dashes, provided that (1) the first character in the string is an upper-case letter, and (2) the final character is neither an underscore nor a dash. Give parse trees for BB-8 and case_1. ID3 = the set of strings axbx -- any number of a's followed by an equal number of b's. Give parse trees for the empty string (i.e. O a's and Ob's) and aabb. Boolean Expression Grammar Write a grammar for Boolean expressions might be simple literals like 3 or 97 or may be more complex syntactic units like (3+x)/4. They evaluate to a number. You needn't concern yourself with their structure; just that they can be used as below. Boolean expressions include the literals TRUE and FALSE; they can be combined with the unary operator ! (meaning NOT) and binary operators && and II (meaning AND and OR). Also, arithmetic expressions can be combined with the following binary operators to form new Boolean expressions: ,, !=. When your grammar is complete, you should be able to derive parse trees for expressions like the following: TRUE FALSE FALSE && !TRUE 27= TRUE FALSE

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

4 Identify the major types of adjusting entries.

Answered: 1 week ago

Question

14-18 Compare the two major types of planning and control tools.

Answered: 1 week ago