+ c. Write a BNF grammar and a regular expression that describes the structure of US telephone numbers, which can either be (xxx)xxx-xxxx or XXX-XXXX, where x is a digit from 0 to 9. Grammar ::= | ::= "(" ")" "-" "-" ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" Regular expression (\(\d{3}\)\d{3}-\d{4}|\d{3}-\d{4})
+ c. Write a BNF grammar and a regular expression that describes the structure of US telephone numbers, which can either be (xxx)xxx-xxxx or XXX-XXXX, where x is a digit from 0 to 9. Grammar ::= | ::= "(" ")" "-" "-" ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" Regular expression (\(\d{3}\)\d{3}-\d{4}|\d{3}-\d{4})
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.5: Virtual Functions
Problem 5E
Related questions
Question
Can someone tell me if this is right please?

Transcribed Image Text:+
c. Write a BNF grammar and a regular expression that describes the
structure of US telephone numbers, which can either be (xxx)xxx-xxxx or
XXX-XXXX, where x is a digit from 0 to 9.
Grammar
<telephone_number> ::= <format1> | <format2>
<format1> ::= "(" <digit> <digit> <digit> ")" <digit> <digit> <digit> "-"
<digit> <digit> <digit> <digit>
<format2> <digit> <digit> <digit> "-" <digit> <digit> <digit> <digit>
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
Regular expression
(\(\d{3}\)\d{3}-\d{4}|\d{3}-\d{4})
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Recommended textbooks for you

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage

C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage

EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT

Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning

C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning