Question

Write out a regular expression for C comments in Lex notation.a.Refer to Sec 2.2.3 for further info; b.Show enough details to receive full credits.

Write out a regular expression for C comments in Lex notation.a.Refer to Sec 2.2.3 for further info; b.Show enough details to receive full credits.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

comments in c means the lines that start with double slash. so regular expression can be easily written as follows.

(\/*)([^*]|\*+[^*\/])*\*+(\/)

The first bracket holds the pattern "/*"

[^*]\* this part explains that it matches a character except * with a *

+ explains that the patten before it should match one or more times

[^*\/])*\* matches a character except a * and / followed by a star with many number of times

(\/) delimited by a /

so the basic logic here is a sentence that starts with "/*" and ends with "*/" will be matched with any number of stars in between

Add a comment
Know the answer?
Add Answer to:
Write out a regular expression for C comments in Lex notation.a.Refer to Sec 2.2.3 for further info; b.Show enough details to receive full credits.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Problem Specification: Write a C++ program to calculate student’s GPA for the semester in your class. For each student, the program should accept a student’s name, ID number and the number of courses...

    Problem Specification:Write a C++ program to calculate student’s GPA for the semester in your class. For each student,the program should accept a student’s name, ID number and the number of courses he/she istaking, then for each course the following data is needed the course number a string e.g. BU 101 course credits “an integer” grade received for the course “a character”.The program should display each student’s information and their courses information. It shouldalso display the GPA for the semester. The...

  • Write a C++ computer program that simulates the action of an elevator that is out of...

    Write a C++ computer program that simulates the action of an elevator that is out of order. After simulating the motion of the elevator, your program will display a bar chart that shows the number of times the elevator stays on each floor of a twenty-five-story building. When you arrive on the scene to begin studying the elevator, it is on the twelfth floor of the twenty-five-story building. Every five minutes the elevator either moves up one floor or down...

  • summatize the following info and break them into differeng key points. write them in yojr own...

    summatize the following info and break them into differeng key points. write them in yojr own words   apartus 6.1 Introduction—The design of a successful hot box appa- ratus is influenced by many factors. Before beginning the design of an apparatus meeting this standard, the designer shall review the discussion on the limitations and accuracy, Section 13, discussions of the energy flows in a hot box, Annex A2, the metering box wall loss flow, Annex A3, and flanking loss, Annex...

  • Using the book, write another paragraph or two: write 170 words: Q: Compare the assumptions of...

    Using the book, write another paragraph or two: write 170 words: Q: Compare the assumptions of physician-centered and collaborative communication. How is the caregiver’s role different in each model? How is the patient’s role different? Answer: Physical-centered communication involves the specialists taking control of the conversation. They decide on the topics of discussion and when to end the process. The patient responds to the issues raised by the caregiver and acts accordingly. On the other hand, Collaborative communication involves a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT