Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have recently designed Glorp, the hot new programming language everyone is tal

ID: 3793241 • Letter: I

Question

I have recently designed Glorp, the hot new programming language everyone is talking about. I’m concerned that there is no way to create block comments, though, and suspect this might severely hurt the uptake of Glorp. I’ve decided that a block comment in the Glorp programming language is a substring of a string which is a Glorp program that begins with ‘/0’, ends with ‘0/’, and does not contain ‘0/’ except as the last characters. For ease of use, programs written in Glorp can only use symbols from the alphabet = {x, y, 0, /}. I use regular expressions as pattern matchers to identify

the language of strings that encode Glorp programs, but I’m stumped about how to design a regular expression that generates the language

L = {w | w is a block comment in the Glorp programming language}.

Explanation / Answer

we modify regular expression from 1-6 steps by taking more geberalisation
1)/.0/

2)replacing the . with [^]
/(.|[ ])0/

3)/([^0]|[ ])0/

4)/([^0]|[ ]|(([^/]|[ ])))0/

5)/([^0]|[ ]|(+([^0/]|[ ])))0/


final solution

6) /([^0]|[ ]|(+([^0/]|[ ])))0/