Now that you know a bit about BNF's, try writing a grammar(productions) for the language of a
Fantastic news! We've Found the answer you've been seeking!
Question:
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.
Related Book For
College Mathematics for Business Economics Life Sciences and Social Sciences
ISBN: 978-0321614001
12th edition
Authors: Raymond A. Barnett, Michael R. Ziegler, Karl E. Byleen
Posted Date: