34 lines
1.1 KiB
Text
34 lines
1.1 KiB
Text
/* A program to remove comments from text. */
|
|
strip: procedure options (main); /* 8/1/2011 */
|
|
declare text character (80) varying;
|
|
declare (j, k) fixed binary;
|
|
|
|
on endfile (sysin) stop;
|
|
|
|
do forever;
|
|
get edit (text) (L);
|
|
do until (k = 0);
|
|
k = index(text, '/*');
|
|
if k > 0 then /* we have a start of comment. */
|
|
do;
|
|
/* Look for end of comment. */
|
|
j = index(text, '*/', k+2);
|
|
if j > 0 then
|
|
do;
|
|
text = substr(text, 1, k-1) ||
|
|
substr(text, j+2, length(text)-(j+2)+1);
|
|
end;
|
|
else
|
|
do; /* The comment continues onto the next line. */
|
|
put skip list ( substr(text, 1, k-1) );
|
|
more: get edit (text) (L);
|
|
j = index(text, '*/');
|
|
if j = 0 then do; put skip; go to more; end;
|
|
text = substr(text, j+2, length(text) - (j+2) + 1);
|
|
end;
|
|
end;
|
|
end;
|
|
put skip list (text);
|
|
end;
|
|
|
|
end strip;
|