Strip block comments: Difference between revisions

Added 11l
(Added Delphi example)
(Added 11l)
Line 40:
{{Template:Strings}}
<br><br>
 
=={{header|11l}}==
<lang 11l>F strip_comments(s, b_delim = ‘/*’, e_delim = ‘*/’)
V r = ‘’
V i = 0
L
V? p = s.find(b_delim, i)
I p == N
L.break
r ‘’= s[i .< p]
V? e = s.find(e_delim, p + b_delim.len)
assert(e != N)
i = e + e_delim.len
r ‘’= s[i..]
R r
 
V text = ‘
/**
* Some comments
* longer comments here that we can parse.
*
* Rahoo
*/
function subroutine() {
a = /* inline comment */ b + c ;
}
/*/ <-- tricky comments */
 
/**
* Another comment.
*/
function something() {
}’
 
print(strip_comments(text))</lang>
 
{{out}}
<pre>
 
 
function subroutine() {
a = b + c ;
}
 
 
 
function something() {
}
</pre>
 
=={{header|Ada}}==
1,481

edits