Answered step by step
Verified Expert Solution
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started