+ 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
icon
Related questions
Question

Can someone tell me if this is right please?

+
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})
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
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning