Strip block comments: Difference between revisions

Content added Content deleted
(→‎{{header|Fortran}}: Once one has an axe, ...)
Line 1,279: Line 1,279:


function something() {
}
</pre>

=={{header|Phix}}==
<lang Phix>constant test = """
/**
* Some comments
* longer comments here that we can parse.
*
* Rahoo
*/
function subroutine() {
a = /* inline comment */ b + c ;
}
/*/ <-- tricky comments */

/**
* Another comment.
*/
function something() {
}
"""

function strip_comments(string text, startc="/*", endc="*/")
while 1 do
integer startp = match(startc,text)
if startp=0 then exit end if
integer endp = match(endc,text,startp+length(startc))
if endp=0 then
puts(1,"error, aborting...")
abort(0)
end if
text[startp..endp+length(endc)-1] = ""
end while
return text
end function

puts(1,strip_comments(test))</lang>
{{out}}
<pre>

function subroutine() {
a = b + c ;
}



function something() {
function something() {
}
}