Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,15 @@
|
|||
(edit 'preferences)
|
||||
;; current contents to edit is displayed in the input box
|
||||
(define (preferences)
|
||||
(define-syntax-rule (++ n) (begin (set! n (1+ n)) n))
|
||||
(define-syntax-rule (% a b) (modulo a b))
|
||||
;; (lib 'gloops)
|
||||
(lib 'timer))
|
||||
|
||||
;; enter new preferences
|
||||
(define (preferences)
|
||||
(define FULLNAME "Foo Barber")
|
||||
(define FAVOURITEFRUIT 'banana)
|
||||
(define NEEDSPELLING #t)
|
||||
; SEEDSREMOVED
|
||||
(define OTHERFAMILY '("Rhu Barber" "Harry Barber")))
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
;; press F5 or COMMAND-R to reload
|
||||
EchoLisp - 2.13.12
|
||||
📗 local-db: db.version: 13
|
||||
|
||||
;; enter parameters names :
|
||||
NEEDSPELLING → #t
|
||||
FAVOURITEFRUIT → banana
|
||||
SEEDSREMOVED
|
||||
😡 error: #|user| : unbound variable : SEEDSREMOVED
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Sub split (s As Const String, sepList As Const String, result() As String)
|
||||
If s = "" OrElse sepList = "" Then
|
||||
Redim result(0)
|
||||
result(0) = s
|
||||
Return
|
||||
End If
|
||||
Dim As Integer i, j, count = 0, empty = 0, length
|
||||
Dim As Integer position(Len(s) + 1)
|
||||
position(0) = 0
|
||||
|
||||
For i = 0 To len(s) - 1
|
||||
For j = 0 to Len(sepList) - 1
|
||||
If s[i] = sepList[j] Then
|
||||
count += 1
|
||||
position(count) = i + 1
|
||||
End If
|
||||
Next j
|
||||
Next i
|
||||
|
||||
Redim result(count)
|
||||
If count = 0 Then
|
||||
result(0) = s
|
||||
Return
|
||||
End If
|
||||
|
||||
position(count + 1) = len(s) + 1
|
||||
|
||||
For i = 1 To count + 1
|
||||
length = position(i) - position(i - 1) - 1
|
||||
result(i - 1) = Mid(s, position(i - 1) + 1, length)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Type ConfigData
|
||||
fullName As String
|
||||
favouriteFruit As String
|
||||
needsPeeling As Boolean
|
||||
seedsRemoved As Boolean
|
||||
otherFamily(Any) As String
|
||||
End Type
|
||||
|
||||
Sub readConfigData(fileName As String, cData As ConfigData)
|
||||
Dim fileNum As Integer = FreeFile
|
||||
Open fileName For Input As #fileNum
|
||||
If err > 0 Then
|
||||
Print "File could not be opened"
|
||||
Sleep
|
||||
End
|
||||
End If
|
||||
Dim ln As String
|
||||
While Not Eof(fileNum)
|
||||
Line Input #fileNum, ln
|
||||
If ln = "" OrElse Left(ln, 1) = "#" OrElse Left(ln, 1) = ";" Then Continue While
|
||||
If UCase(Left(ln, 8)) = "FULLNAME" Then
|
||||
cData.fullName = Trim(Mid(ln, 9), Any " =")
|
||||
ElseIf UCase(Left(ln, 14)) = "FAVOURITEFRUIT" Then
|
||||
cData.favouriteFruit = Trim(Mid(ln, 15), Any " =")
|
||||
ElseIf UCase(Left(ln, 12)) = "NEEDSPEELING" Then
|
||||
Dim s As String = Trim(Mid(ln, 13), Any " =")
|
||||
If s = "" OrElse UCase(s) = "TRUE" Then
|
||||
cData.needsPeeling = True
|
||||
Else
|
||||
cData.needsPeeling = False
|
||||
End If
|
||||
ElseIf UCase(Left(ln, 12)) = "SEEDSREMOVED" Then
|
||||
Dim s As String = Trim(Mid(ln, 13), Any " =")
|
||||
If s = "" OrElse UCase(s) = "TRUE" Then
|
||||
cData.seedsRemoved = True
|
||||
Else
|
||||
cData.seedsRemoved = False
|
||||
End If
|
||||
ElseIf UCase(Left(ln, 11)) = "OTHERFAMILY" Then
|
||||
split Mid(ln, 12), ",", cData.otherFamily()
|
||||
For i As Integer = LBound(cData.otherFamily) To UBound(cData.otherFamily)
|
||||
cData.otherFamily(i) = Trim(cData.otherFamily(i), Any " =")
|
||||
Next
|
||||
End If
|
||||
Wend
|
||||
Close #fileNum
|
||||
End Sub
|
||||
|
||||
Dim fileName As String = "config.txt"
|
||||
Dim cData As ConfigData
|
||||
readConfigData fileName, cData
|
||||
Print "Full name = "; cData.fullName
|
||||
Print "Favourite fruit = "; cData.favouriteFruit
|
||||
Print "Needs peeling = "; cData.needsPeeling
|
||||
Print "Seeds removed = "; cData.seedsRemoved
|
||||
For i As Integer = LBound(cData.otherFamily) To UBound(cData.otherFamily)
|
||||
Print "Other family("; Str(i); ") = "; cData.otherFamily(i)
|
||||
Next
|
||||
Print
|
||||
Print "Press any key to quit"
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
local(config = '# This is a configuration file in standard configuration file format
|
||||
#
|
||||
# Lines beginning with a hash or a semicolon are ignored by the application
|
||||
# program. Blank lines are also ignored by the application program.
|
||||
|
||||
# This is the fullname parameter
|
||||
|
||||
FULLNAME Foo Barber
|
||||
|
||||
# This is a favourite fruit
|
||||
FAVOURITEFRUIT = banana
|
||||
|
||||
# This is a boolean that should be set
|
||||
NEEDSPEELING
|
||||
|
||||
# This boolean is commented out
|
||||
; SEEDSREMOVED
|
||||
|
||||
# Configuration option names are not case sensitive, but configuration parameter
|
||||
# data is case sensitive and may be preserved by the application program.
|
||||
|
||||
# An optional equals sign can be used to separate configuration parameter data
|
||||
# from the option name. This is dropped by the parser.
|
||||
|
||||
# A configuration option may take multiple parameters separated by commas.
|
||||
# Leading and trailing whitespace around parameter names and parameter data fields
|
||||
# are ignored by the application program.
|
||||
|
||||
OTHERFAMILY Rhu Barber, Harry Barber
|
||||
')
|
||||
// if config is in a file collect it like this
|
||||
//local(config = file('path/and/file.name') -> readstring)
|
||||
|
||||
define getconfig(term::string, config::string) => {
|
||||
|
||||
local(
|
||||
regexp = regexp(-find = `(?m)^` + #term + `($|\s*=\s*|\s+)(.*)$`, -input = #config, -ignorecase),
|
||||
result
|
||||
)
|
||||
|
||||
while(#regexp -> find) => {
|
||||
#result = (#regexp -> groupcount > 1 ? (#regexp -> matchString(2) -> trim& || true))
|
||||
if(#result -> asstring >> ',') => {
|
||||
#result = #result -> split(',')
|
||||
#result -> foreach => {#1 -> trim}
|
||||
}
|
||||
return #result
|
||||
}
|
||||
return false
|
||||
|
||||
}
|
||||
|
||||
local(
|
||||
fullname = getconfig('FULLNAME', #config),
|
||||
favorite = getconfig('FAVOURITEFRUIT', #config),
|
||||
sedsremoved = getconfig('SEEDSREMOVED', #config),
|
||||
needspeel = getconfig('NEEDSPEELING', #config),
|
||||
otherfamily = getconfig('OTHERFAMILY', #config)
|
||||
)
|
||||
|
||||
#fullname
|
||||
'<br />'
|
||||
#favorite
|
||||
'<br />'
|
||||
#sedsremoved
|
||||
'<br />'
|
||||
#needspeel
|
||||
'<br />'
|
||||
#otherfamily
|
||||
'<br />'
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<@ DEFUDRLIT>__ReadConfigurationFile|
|
||||
<@ LETSCPPNTPARSRC>Data|1</@><@ OMT> read file into locally scope variable</@>
|
||||
<@ LETCGDLSTLLOSCP>List|Data</@><@ OMT> split Data into a list of lines </@>
|
||||
<@ OMT> Remove comment lines, and blank lines </@>
|
||||
<@ ACTOVRBEFLSTLIT>List|;</@>
|
||||
<@ ACTOVRBEFLSTLIT>List|#</@>
|
||||
<@ ACTRMELST>List</@>
|
||||
<@ OMT> Iterate over the lines of the list </@>
|
||||
<@ ITEENULSTLit>List|
|
||||
<@ LETVARUPTVALLSTLIT>key|...| </@>
|
||||
<@ LETVARAFTVALLSTLIT>val|...| </@>
|
||||
<@ OMT> test for an empty key (in the case of a boolean) </@>
|
||||
<@ TSTVARLIT>key|</@>
|
||||
<@ IFE><@ LETPNTVARVARLIT>val|__True</@></@>
|
||||
<@ ELS>
|
||||
<@ TSTGT0ATBVARLIT>val|,</@>
|
||||
<@ IFE><@ ACTEXEEMMCAP><&prot; LETCNDLSTLITLIT>&key;&pipe;&val;&pipe;, </&prot;></@></@>
|
||||
<@ ELS><@ LETPNTVARVARVAR>key|val</@></@>
|
||||
</@>
|
||||
</@>
|
||||
</@>
|
||||
|
||||
<@ ACTUDRLIT>__ReadConfigurationFile|c:\rosetta.config</@>
|
||||
<@ SAYVAR>FAVOURITEFRUIT</@>
|
||||
<@ SAYVAR>FULLNAME</@>
|
||||
<@ SAYVAR>NEEDSPEELING</@>
|
||||
<@ SAYDMPLST>OTHERFAMILY</@>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
var fullname = (var favouritefruit = "");
|
||||
var needspeeling = (var seedsremoved = false);
|
||||
var otherfamily = [];
|
||||
|
||||
ARGF.each { |line|
|
||||
var(key, value) = line.strip.split(/\h+/, 2)...;
|
||||
|
||||
given(key) {
|
||||
when (nil) { }
|
||||
when (/^([#;]|\h*$)/) { }
|
||||
when ("FULLNAME") { fullname = value }
|
||||
when ("FAVOURITEFRUIT") { favouritefruit = value }
|
||||
when ("NEEDSPEELING") { needspeeling = true }
|
||||
when ("SEEDSREMOVED") { seedsremoved = true }
|
||||
when ("OTHERFAMILY") { otherfamily = value.split(',')»strip»() }
|
||||
default { say "#{key}: unknown key" }
|
||||
}
|
||||
}
|
||||
|
||||
say "fullname = #{fullname}";
|
||||
say "favouritefruit = #{favouritefruit}";
|
||||
say "needspeeling = #{needspeeling}";
|
||||
say "seedsremoved = #{seedsremoved}";
|
||||
|
||||
otherfamily.each_kv {|i, name|
|
||||
say "otherfamily(#{i+1}) = #{name}";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue