Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,27 @@
' FB 1.05.0 Win64
Sub stripComment(s As String, commentMarkers As String)
If s = "" Then Return
Dim i As Integer = Instr(s, Any commentMarkers)
If i > 0 Then
s = Left(s, i - 1)
s = Trim(s) '' removes both leading and trailing whitespace
End If
End Sub
Dim s(1 To 4) As String = _
{ _
"apples, pears # and bananas", _
"apples, pears ; and bananas", _
"# this is a comment", _
" # this is a comment with leading whitespace" _
}
For i As Integer = 1 To 4
stripComment(s(i), "#;")
Print s(i), " => Length ="; Len(s(i))
Next
Print
Print "Press any key to quit"
Sleep

View file

@ -0,0 +1,7 @@
import strutils
proc removeComments(line, sep): string =
line.split(sep)[0].strip(leading = false)
echo removeComments("apples, pears # and bananas", '#')
echo removeComments("apples, pears ; and bananas", ';')

View file

@ -0,0 +1,4 @@
: stripComments(s, markers)
| firstMarker |
markers map(#[ s indexOf ]) reduce(#min) ->firstMarker
s firstMarker ifNotNull: [ left(firstMarker 1 - ) ] strip ;

View file

@ -0,0 +1,17 @@
function strip_comments(string s, sequence comments={"#",";"})
for i=1 to length(comments) do
integer k = match(comments[i],s)
if k then
s = s[1..k-1]
s = trim_tail(s)
end if
end for
return s
end function
?strip_comments("apples, pears # and bananas")
?strip_comments("apples, pears ; and bananas")
?strip_comments("apples, pears and bananas ")
?strip_comments(" WS_CAPTION = #00C00000, -- = WS_BORDER+WS_DLGFRAME")
?strip_comments(" WS_CAPTION = #00C00000, -- = WS_BORDER+WS_DLGFRAME",{"--"})
?strip_comments(" title = \"--Title--\"",{"--"})

View file

@ -0,0 +1,13 @@
aList = 'apples, pears # and bananas'
see aList + nl
see stripComment(aList) + nl
aList = 'apples, pears // and bananas'
see aList + nl
see stripComment(aList) + nl
func stripComment bList
nr = substr(bList,"#")
if nr > 0 cList = substr(bList,1,nr-1) ok
nr = substr(bList,"//")
if nr > 0 cList = substr(bList,1,nr-1) ok
return cList

View file

@ -0,0 +1,9 @@
func strip_comment(s) {
(s - %r'[#;].*').strip;
}
[" apples, pears # and bananas",
" apples, pears ; and bananas",
" apples, pears "].each { |s|
say strip_comment(s).dump;
};

View file

@ -0,0 +1 @@
sub("[#;].*";"") | sub("^\\s+";"") | sub("\\s+$";"")

View file

@ -0,0 +1,20 @@
# define whitespace here as a tab, space, newline, return or form-feed character:
def is_whitespace: . as $in | " \n\r\f\t" | index($in);
def ltrim:
if .[0:1] | is_whitespace then (.[1:]|ltrim) else . end;
def rtrim:
if .[length-1:] | is_whitespace then .[0:length-1]|rtrim else . end;
def trim: ltrim | rtrim;
def strip_comment:
index("#") as $i1 | index(";") as $i2
| (if $i1 then if $i2 then [$i1, $i2] | min
else $i1
end
else $i2
end ) as $ix
| if $ix then .[0:$ix] else . end
| trim;

View file

@ -0,0 +1 @@
" abc ; def # ghi" | strip_comment