diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/ini/ini.tm | 4 | ||||
| -rw-r--r-- | examples/log/log.tm | 10 | ||||
| -rw-r--r-- | examples/tomodeps/tomodeps.tm | 12 | ||||
| -rw-r--r-- | examples/wrap/wrap.tm | 6 |
4 files changed, 16 insertions, 16 deletions
diff --git a/examples/ini/ini.tm b/examples/ini/ini.tm index 4e5ec776..5952bb00 100644 --- a/examples/ini/ini.tm +++ b/examples/ini/ini.tm @@ -8,7 +8,7 @@ _HELP := " func parse_ini(path:Path -> {Text:{Text:Text}}): text := path:read() or exit("Could not read INI file: $\[31;1]$(path.text_content)$\[]") - sections := {:Text:@{Text:Text}} + sections := @{:Text:@{Text:Text}} current_section := @{:Text:Text} # Line wraps: @@ -26,7 +26,7 @@ func parse_ini(path:Path -> {Text:{Text:Text}}): value := line:replace($/{..}={..}/, "\2"):trim() current_section:set(key, value) - return {k:v[] for k,v in sections} + return {k:v[] for k,v in sections[]} func main(path:Path, key:Text?): keys := (key or ""):split($|/|) diff --git a/examples/log/log.tm b/examples/log/log.tm index f537b850..89557e55 100644 --- a/examples/log/log.tm +++ b/examples/log/log.tm @@ -3,7 +3,7 @@ use <stdio.h> timestamp_format := CString("%F %T") -logfiles := {:Path} +logfiles := @{:Path} func _timestamp(->Text): c_str := inline C:CString { @@ -17,22 +17,22 @@ func _timestamp(->Text): func info(text:Text, newline=yes): say("$\[2]⚫ $text$\[]", newline) - for file in logfiles: + for file in logfiles[]: file:append("$(_timestamp()) [info] $text$\n") func debug(text:Text, newline=yes): say("$\[32]🟢 $text$\[]", newline) - for file in logfiles: + for file in logfiles[]: file:append("$(_timestamp()) [debug] $text$\n") func warn(text:Text, newline=yes): say("$\[33;1]🟡 $text$\[]", newline) - for file in logfiles: + for file in logfiles[]: file:append("$(_timestamp()) [warn] $text$\n") func error(text:Text, newline=yes): say("$\[31;1]🔴 $text$\[]", newline) - for file in logfiles: + for file in logfiles[]: file:append("$(_timestamp()) [error] $text$\n") func add_logfile(file:Path): diff --git a/examples/tomodeps/tomodeps.tm b/examples/tomodeps/tomodeps.tm index 15655756..fbe297ec 100644 --- a/examples/tomodeps/tomodeps.tm +++ b/examples/tomodeps/tomodeps.tm @@ -14,7 +14,7 @@ func _get_file_dependencies(file:Path -> {Dependency}): !! Could not read file: $file return {:Dependency} - deps := {:Dependency} + deps := @{:Dependency} if lines := file:by_line(): for line in lines: if line:matches($/use {..}.tm/): @@ -23,7 +23,7 @@ func _get_file_dependencies(file:Path -> {Dependency}): else if line:matches($/use {id}/): module_name := line:replace($/use {..}/, "\1") deps:add(Dependency.Module(module_name)) - return deps + return deps[] func _build_dependency_graph(dep:Dependency, dependencies:@{Dependency:{Dependency}}): return if dependencies:has(dep) @@ -34,9 +34,9 @@ func _build_dependency_graph(dep:Dependency, dependencies:@{Dependency:{Dependen _get_file_dependencies(path) is Module(module): dir := (~/.local/share/tomo/installed/$module) - module_deps := {:Dependency} - visited := {:Path} - unvisited := {f:resolved() for f in dir:files() if f:ends_with(".tm")} + module_deps := @{:Dependency} + visited := @{:Path} + unvisited := @{f:resolved() for f in dir:files() if f:ends_with(".tm")} while unvisited.length > 0: file := unvisited.items[-1] unvisited:remove(file) @@ -48,7 +48,7 @@ func _build_dependency_graph(dep:Dependency, dependencies:@{Dependency:{Dependen unvisited:add(f) is Module(m): module_deps:add(file_dep) - module_deps + module_deps[] dependencies:set(dep, dep_deps) diff --git a/examples/wrap/wrap.tm b/examples/wrap/wrap.tm index 1c43470a..b6cf1403 100644 --- a/examples/wrap/wrap.tm +++ b/examples/wrap/wrap.tm @@ -33,7 +33,7 @@ func wrap(text:Text, width:Int, min_split=3, hyphen="-" -> Text): ... and I can't split it without splitting into chunks smaller than $min_split. ") - lines := [:Text] + lines := @[:Text] line := "" for word in text:split($/{whitespace}/): letters := word:split() @@ -93,10 +93,10 @@ func main(files:[Path], width=80, inplace=no, min_split=3, rewrap=yes, hyphen=UN (/dev/stdout) first := yes - wrapped_paragraphs := [:Text] + wrapped_paragraphs := @[:Text] for paragraph in text:split($/{2+ nl}/): wrapped_paragraphs:insert( wrap(paragraph, width=width, min_split=min_split, hyphen=hyphen) ) - out:write(\n\n:join(wrapped_paragraphs) ++ \n) + out:write(\n\n:join(wrapped_paragraphs[]) ++ \n) |
