Uploaded by Gökalp Umut Barlas

CS315-02 Quiz 3

advertisement
Name :
ID
:
CS315 Programming Languages
Section #2 - Quiz #3
Date: Oct 4, 2023
Question:
Write a lex specification that will filter only the uppercase strings in the
input stream and display them surrounded by * character.
See a sample run below with its executable named filter-uppercase:
adayanik@dijkstra:$ cat test
zxadtn26AABbc-542XYZ0092.?a+-5
zxdtn26AABbXYc-542AATXYZ0092.?PQR
adayanik@dijkstra:$ cat test | ./filter-uppercase
*AAB**XYZ*
*AAB**XY**AATXYZ**PQR*
Answer:
%option main
%%
[A-Z]+
.
printf("*%s*", yytext);
;
Download