Strip block comments: Difference between revisions

no edit summary
No edit summary
Line 636:
}
}</lang>
 
=={{header|Liberty BASIC}}==
<lang lb>
global CRLF$
CRLF$ =chr$( 13) +chr$( 10)
 
sample$ =" /**"+CRLF$+_
" * Some comments"+CRLF$+_
" * longer comments here that we can parse."+CRLF$+_
" *"+CRLF$+_
" * Rahoo "+CRLF$+_
" */"+CRLF$+_
" function subroutine() {"+CRLF$+_
" a = /* inline comment */ b + c ;"+CRLF$+_
" }"+CRLF$+_
" /*/ <-- tricky comments */"+CRLF$+_
""+CRLF$+_
" /**"+CRLF$+_
" * Another comment."+CRLF$+_
" */"+CRLF$+_
" function something() {"+CRLF$+_
" }"+CRLF$
 
startDelim$ ="/*"
finishDelim$ ="*/"
 
print "________________________________"
print sample$
print "________________________________"
print blockStripped$( sample$, startDelim$, finishDelim$)
print "________________________________"
 
end
 
function blockStripped$( in$, s$, f$)
for i =1 to len( in$) -len( s$)
if mid$( in$, i, len( s$)) =s$ then
i =i +len( s$)
do
if mid$( in$, i, 2) =CRLF$ then blockStripped$ =blockStripped$ +CRLF$
i =i +1
loop until ( mid$( in$, i, len( f$)) =f$) or ( i =len( in$) -len( f$))
i =i +len( f$) -1
else
blockStripped$ =blockStripped$ +mid$( in$, i, 1)
end if
next i
end function
</lang>
<pre>
 
 
 
 
 
function subroutine() {
a = b + c ;
}
 
 
 
 
 
function something() {
}
 
</pre>
 
=={{header|Lua}}==
Anonymous user