34 lines
726 B
Text
34 lines
726 B
Text
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))
|