Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

about the correction of regex Java (as well as C and C++) allows comments delimited by / and /. This kind of comment can be

image text in transcribed

about the correction of regex

image text in transcribed

Java (as well as C and C++) allows comments delimited by "/" and "/". This kind of comment can be defined in English as follows: A comment consists of three parts: 1. a slash followed by a star, followed by 2. the body of the comment, followed by 3. a star followed by a slash. The body of the comment can be empty, or can contain any characters except the two character sequence"./". Note that the body of a comment can include stars and slashes, just not "/", Assume that the following JLex macros have been defined: SLASH STAR = [/] [*] Question 1: Below are 5 incorrect JLex patterns for the kind of comment defined above. For each pattern, explain what is wrong. For example, you might say The paller does not allow the comment body to include stars, or The pattern does allow the comment include *. If the pattern both disallows some "good" comments and allows some "bad" comments, you need to give two explanations, one for each issue. In addition to the explanations, you need to provide example strings that illustrate each issue; i.e., give a string that is not matched by the pattern but is a "good" comment and/or give a string that is matched by the pattern but is a "bad" comment. Be sure that it is clear whether your example strings are intended to be "good" or "bad" comments. (SLASH) (STAR)(*/)*(STAR) (SLASH) (SLASH) (STAR) ( . ) * {STAR} {SLASH} (SLASH (STAR) (**1(STAR)*[**/]) (STAR)+(SLASH) SLASH) (STAR) ( *111/])+(STAR) (SLASH) SLASH) (STAR) [**]*(STAR)+ (SLASH) + Question 2: Give a correct JLex pattern for comments as defined above. You may define and use additional macros. Make your pattern as readable as possible. Java (as well as C and C++) allows comments delimited by "/*" and "+/". This kind of comment can be defined in English as follows: A comment consists of three parts: 1. a slash followed by a star, followed by 2. the body of the comment, followed by 3. a star followed by a slash. The body of the comment can be empty, or can contain any characters except the two character sequence "+/". Note that the body of a comment can include stars and slashes, just not "*/". Assume that the following JLex macros have been defined: SLASH STAR = [/] Question 1: Below are 5 incorrect JLex patterns for the kind of comment defined above. For each pattern, explain what is wrong. For example, you might say The pattern does not allow the comment body to include stars, or The pattern does allow the comment body to include */. If the pattern both disallows some "good" comments and allows some "bad" comments, you need to give two explanations, one for each issue. In addition to the explanations, you need to provide example strings that illustrate each issue; i.e., give a string that is not matched by the pattern but is a "good" comment and/or give a string that is matched by the pattern but is a "bad" comment. Be sure that it is clear whether your example strings are intended to be "good" or "bad" comments. {SLASH} {STAR} [*(*/)]*{STAR} {SLASH) {SLASH} {STAR} ( )*{STAR} {SLASH} {SLASH} {STAR}([**]*(STAR} +[**/]) * {STAR} + {SLASH} {SLASH}{STAR}([**][*/])+{STAR} {SLASH} {SLASH}{STAR} [**]*{STAR}+{SLASH}+ Question 2: Give a correct JLex pattern for comments as defined above. You may define and use additional macros. Make your pattern as readable as possible. Java (as well as C and C++) allows comments delimited by "/" and "/". This kind of comment can be defined in English as follows: A comment consists of three parts: 1. a slash followed by a star, followed by 2. the body of the comment, followed by 3. a star followed by a slash. The body of the comment can be empty, or can contain any characters except the two character sequence"./". Note that the body of a comment can include stars and slashes, just not "/", Assume that the following JLex macros have been defined: SLASH STAR = [/] [*] Question 1: Below are 5 incorrect JLex patterns for the kind of comment defined above. For each pattern, explain what is wrong. For example, you might say The paller does not allow the comment body to include stars, or The pattern does allow the comment include *. If the pattern both disallows some "good" comments and allows some "bad" comments, you need to give two explanations, one for each issue. In addition to the explanations, you need to provide example strings that illustrate each issue; i.e., give a string that is not matched by the pattern but is a "good" comment and/or give a string that is matched by the pattern but is a "bad" comment. Be sure that it is clear whether your example strings are intended to be "good" or "bad" comments. (SLASH) (STAR)(*/)*(STAR) (SLASH) (SLASH) (STAR) ( . ) * {STAR} {SLASH} (SLASH (STAR) (**1(STAR)*[**/]) (STAR)+(SLASH) SLASH) (STAR) ( *111/])+(STAR) (SLASH) SLASH) (STAR) [**]*(STAR)+ (SLASH) + Question 2: Give a correct JLex pattern for comments as defined above. You may define and use additional macros. Make your pattern as readable as possible. Java (as well as C and C++) allows comments delimited by "/*" and "+/". This kind of comment can be defined in English as follows: A comment consists of three parts: 1. a slash followed by a star, followed by 2. the body of the comment, followed by 3. a star followed by a slash. The body of the comment can be empty, or can contain any characters except the two character sequence "+/". Note that the body of a comment can include stars and slashes, just not "*/". Assume that the following JLex macros have been defined: SLASH STAR = [/] Question 1: Below are 5 incorrect JLex patterns for the kind of comment defined above. For each pattern, explain what is wrong. For example, you might say The pattern does not allow the comment body to include stars, or The pattern does allow the comment body to include */. If the pattern both disallows some "good" comments and allows some "bad" comments, you need to give two explanations, one for each issue. In addition to the explanations, you need to provide example strings that illustrate each issue; i.e., give a string that is not matched by the pattern but is a "good" comment and/or give a string that is matched by the pattern but is a "bad" comment. Be sure that it is clear whether your example strings are intended to be "good" or "bad" comments. {SLASH} {STAR} [*(*/)]*{STAR} {SLASH) {SLASH} {STAR} ( )*{STAR} {SLASH} {SLASH} {STAR}([**]*(STAR} +[**/]) * {STAR} + {SLASH} {SLASH}{STAR}([**][*/])+{STAR} {SLASH} {SLASH}{STAR} [**]*{STAR}+{SLASH}+ Question 2: Give a correct JLex pattern for comments as defined above. You may define and use additional macros. Make your pattern as readable as possible

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions