Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (20pt) We have discussed a simple calculator (textbook p.54, slide 2a.16), where the C-style com- ments are described using this regular expressions (

1. (20pt) We have discussed a simple calculator (textbook p.54, slide 2a.16), where the C-style com- ments are described using this regular expressions ( is newline): comment /* (non-* | * // (non- ) non-/)**+/ Actually, the regular expression above for C comments is wrong! (Always think for yourself; there can be errors and incorrect information anywhere!) You are required to: (a) (10pt) Prove there is an error; that means the regular expression either accepts a string which is not a comment, or fails to accept a valid comment. You need to give an example of such a string. Explain why your example is correct. (b) (10pt) Give a valid regular expression. This should be a nice, intuitive looking regular expres- sion, not something horrible produced by jflap. (You can use jflap if you want, but the result must look readable.) You are allowed to use non-x (or x, or [^x]) to denote any character diferent from x; r can also be a set of characters. Explain why your regular expression is correct.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Quantum Chemistry

Authors: Ira N. Levine

7th edition

321803450, 978-0321803450

More Books

Students also viewed these Programming questions