Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Strip-block-comments/Icon/strip-block-comments-1.icon
Normal file
16
Task/Strip-block-comments/Icon/strip-block-comments-1.icon
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
procedure main()
|
||||
every (unstripped := "") ||:= !&input || "\n" # Load file as one string
|
||||
write(stripBlockComment(unstripped,"/*","*/"))
|
||||
end
|
||||
|
||||
procedure stripBlockComment(s1,s2,s3) #: strip comments between s2-s3 from s1
|
||||
result := ""
|
||||
s1 ? {
|
||||
while result ||:= tab(find(s2)) do {
|
||||
move(*s2)
|
||||
tab(find(s3)|0) # or end of string
|
||||
move(*s3)
|
||||
}
|
||||
return result || tab(0)
|
||||
}
|
||||
end
|
||||
14
Task/Strip-block-comments/Icon/strip-block-comments-2.icon
Normal file
14
Task/Strip-block-comments/Icon/strip-block-comments-2.icon
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
procedure main()
|
||||
every writes(stripBlockComment(!&input,"/*","*/"))
|
||||
end
|
||||
|
||||
procedure stripBlockComment(s,s2,s3)
|
||||
static inC # non-null when inside comment
|
||||
(s||"\n") ? while not pos(0) do {
|
||||
if /inC then
|
||||
if inC := 1(tab(find(s2))\1, move(*s2)) then suspend inC
|
||||
else return tab(0)
|
||||
else if (tab(find(s3))\1,move(*s3)) then inC := &null
|
||||
else fail
|
||||
}
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue