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: 3865076 • 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}. Hint: The regular expression r = /0()0/ is not correct. Believe me, I’ve tried.

Not a programing regular expression, but a model of computation regular expression

Explanation / Answer

Although its not clear enough, given below are few inputs to tackle this.

Linux is powerful enough to extract desired set of strings or any patterns with several options.

grep, regex, sed, awk and their combinations provides you with mulitple possiblities.

One example if you have a file with several blank lines, lines starting with # . If you want to exclude those lines starting with # and remove blank lines, and print only the content of files, you concatenate commands. The below will work for this example:

cat file_name | grep -v ^# | grep -v ^$

Here we are elimintaing lines with # and blank lines in the file

grep -v is for inverse match. Observe that the output is concatenated. Similarly you can try and check for your case.