Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Give production rules in extended Backus–Naur form that generate all decimal numerals consisting of an optional sign, a nonnegative integer, and a decimal fraction that is either the empty string or a decimal point followed by an optional positive integer optionally preceded by some number of zeros.

Short Answer

Expert verified

The production rules in extended Backus–Naur form is,

\(\begin{array}{c}{\bf{numeral :: = sign? nonzerodigit digit*decimal? I sign? 0 decimal?}}\\{\bf{sign :: = + I - }}\\{\bf{nonzerodigit :: = 1 |2 | }}...{\bf{|9}}\\{\bf{digit :: = 0| nonzerodigit}}\\{\bf{decimal :: = digit*}}\end{array}\)

Step by step solution

Achieve better grades quicker with Premium

  • Unlimited AI interaction
  • Study offline
  • Say goodbye to ads
  • Export flashcards

Over 22 million students worldwide already upgrade their learning with Vaia!

01

About Backus-Nour form

The Backus-Naur form is a notation for specifying a type 2 grammar.

Productions in a type 2 grammar have a single non-terminal symbol on the left.

Rather of listing all the productions individually, we can merge all those with the same non terminal symbol on the left-hand side into one statement rather of using the symbolàin a production,

The symbol:: =

All non-terminal symbols are enclosed in brackets (>), and all productions' right-hand sides are listed in the same statement, separated by bars.

02

The Backus-Naur form's additions include the following:

a) "+": denotes that the symbol to the left of it may appear once or more.

b) A symbol or set of symbols denoted by the question mark ("?) to the left of it may appear 0 or 1 times.

c) "*": denotes that the sign to the left of it may appear once or more.

03

Assume that leading 0's are not allowed in the whole number part

Because the problem explicitly mentioned them only for the decimal part. Our rules should allow the optional sign using the question mark character, the integer part consisting of one or more digits, which does not start with a 0 unless 0 is the integer part of the integer, so the decimal part or not.

Note that the decimal part has a decimal point followed by 0 or more digits.

\(\begin{array}{c}{\bf{numeral :: = sign? nonzerodigit digit*decimal? I sign? 0 decimal?}}\\{\bf{sign :: = + I - }}\\{\bf{nonzerodigit :: = 1 |2 | }}...{\bf{|9}}\\{\bf{digit :: = 0| nonzerodigit}}\\{\bf{decimal :: = digit*}}\end{array}\)

Hence, the above production rules in extended Backus–Naur form.

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Construct a derivation of \({{\bf{0}}^{\bf{3}}}{{\bf{1}}^{\bf{3}}}\) using the grammar given in Example 5.

In Exercises 16–22 find the language recognized by the given deterministic finite-state automaton

a) Explain what the productions are in a grammar if the Backus–Naur form for productions is as follows:

\(\begin{array}{*{20}{l}}{{\bf{ < expression > :: = }}\left( {{\bf{ < expression > }}} \right){\bf{ }}\left| {{\bf{ < expression > + < expression > }}} \right|}\\\begin{array}{c}{\bf{\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;}}\,\,\,\,{\bf{ < expression > * < expression > |}}\\\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,\,{\bf{ < variable > }}\end{array}\\{\,\,\,\,\,\,\,\,\,{\bf{ < variable > :: = xly}}}\end{array}\)

b) Find a derivation tree for \(\left( {{\bf{x*y}}} \right){\bf{ + x}}\) in this grammar.

Find a phrase-structure grammar for each of these languages.

a) the set consisting of the bit strings 10, 01, and 101.

b) the set of bit strings that start with 00 and end with one or more 1s.

c) the set of bit strings consisting of an even number of 1s followed by a final 0.

d) the set of bit strings that have neither two consecutive 0s nor two consecutive 1s.

Let G = (V, T, S, P) be the phrase-structure grammar with V = {0, 1, A, S}, T = {0, 1}, and set of productions P consisting of S → 1S, S → 00A, A → 0A, and A → 0.

a) Show that 111000 belongs to the language generated by G.

b) Show that 11001 does not belong to the language generated by G.

c) What is the language generated by G?

See all solutions

Recommended explanations on Math Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free