Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Strip-block-comments/PL-I/strip-block-comments.pli
Normal file
34
Task/Strip-block-comments/PL-I/strip-block-comments.pli
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue