Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Now that you know a bit about BNF's, try writing a grammar(productions) for the language of a phonenumber , which consists of: three digits enclosed

Now that you know a bit about BNF's, try writing a grammar(productions) for the "language" of a phonenumber, which consists of:

  • three digits enclosed in parentheses - the first digit cannotbe "0" (zero)
  • followed by three digits - the first digit cannot be "0"(zero)
  • followed by a "-" (dash)
  • followed by four digits

So, (757)530-4601 is a valid phone number. All the followingnumbers are invalidaccording to thisgrammar:

  • 757-530-4601 (area code is not in parentheses)
  • (757)530.4601 (missing dash after the exchange)
  • (919)-555-5555 (stray dash after area code)
  • (019)555-5555 (area code cannot start with zero)
  • and so on

Once you have a grammar, write down:

  • the derivation of one correct phonenumber - give both the sequence of substitutions and the parse treerepresentation
  • the attempted derivationof one incorrect phone number - list thesequence of substitutions OR draw the parse tree until thederivation "breaks." Write a note explaining why the derivation cango no further.

Step by Step Solution

3.38 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

Grammar for the phonenumber language phonenumber digit digit digit digit digit digit digit di... 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

Step: 3

blur-text-image

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

College Mathematics for Business Economics Life Sciences and Social Sciences

Authors: Raymond A. Barnett, Michael R. Ziegler, Karl E. Byleen

12th edition

321614003, 978-0321614001

More Books

Students also viewed these Electrical Engineering questions

Question

In Problem, find f(x) and simplify. f(x) = (5x2 - 3)6

Answered: 1 week ago