Question: Using Plait ( a sub extension of racket ) , write the grammar of a language that accepts valid phone numbers with the area codes

Using Plait(a sub extension of racket), write the grammar of a language that accepts valid phone numbers with the area codes 787 or 939. A valid phone number has the formar xxx-xxx-xxxx. The xs are digits 0-9.
Define a type digits that can be any digit from 0-9. Define another type three-digits that is a sequence of 3 digits and another type, four-digits that is a sequence of 4 digits. Additionally define the type area code that can be 787 or 939.
Lastly create a function that validates if the phone number inputed is valid. Note: This should not be a program but a language. There must be parsing involved defining the types
use this BNF as reference:
::=
Val() Val() Val() Val()
::="787""939"
Val()787 or 939
::=
Val() Val(1) Val(2) Val(3)
::=
Val() Val(1) Val(2) Val(3) Val(4)
::="0""1""2""3""4""5""6""7""8""9"
Val()0 to 9, corresponding to the digit value

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!