aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-02 16:14:20 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-02 16:14:20 -0400
commit6ec8f20fc506af4af5513803fb9a708e4f7b5040 (patch)
tree8b952073f6eda5b85c375a65c73647a85fa16f27 /examples
parentecaf34247eb0728a913804033cf302dada417028 (diff)
Syntax change: table types are now: `{K=V; default=...}` and tables
use `{:K=V, ...; default=...}`
Diffstat (limited to 'examples')
-rw-r--r--examples/commands/commands.tm8
-rw-r--r--examples/ini/ini.tm8
-rw-r--r--examples/learnxiny.tm4
-rw-r--r--examples/patterns/patterns.tm2
4 files changed, 11 insertions, 11 deletions
diff --git a/examples/commands/commands.tm b/examples/commands/commands.tm
index 26b82790..cbf5439b 100644
--- a/examples/commands/commands.tm
+++ b/examples/commands/commands.tm
@@ -3,8 +3,8 @@
use ./commands.c
use -lunistring
-extern run_command:func(exe:Text, args:[Text], env:{Text,Text}, input:[Byte]?, output:&[Byte]?, error:&[Byte]? -> Int32)
-extern command_by_line:func(exe:Text, args:[Text], env:{Text,Text} -> func(->Text?)?)
+extern run_command:func(exe:Text, args:[Text], env:{Text=Text}, input:[Byte]?, output:&[Byte]?, error:&[Byte]? -> Int32)
+extern command_by_line:func(exe:Text, args:[Text], env:{Text=Text} -> func(->Text?)?)
enum ExitType(Exited(status:Int32), Signaled(signal:Int32), Failed):
func succeeded(e:ExitType -> Bool):
@@ -46,8 +46,8 @@ struct ProgramResult(stdout:[Byte], stderr:[Byte], exit_type:ExitType):
else:
return no
-struct Command(command:Text, args=[:Text], env={:Text,Text}):
- func from_path(path:Path, args=[:Text], env={:Text,Text} -> Command):
+struct Command(command:Text, args=[:Text], env={:Text=Text}):
+ func from_path(path:Path, args=[:Text], env={:Text=Text} -> Command):
return Command(Text(path), args, env)
func result(command:Command, input="", input_bytes=[:Byte] -> ProgramResult):
diff --git a/examples/ini/ini.tm b/examples/ini/ini.tm
index 1c90b715..1e8e015f 100644
--- a/examples/ini/ini.tm
+++ b/examples/ini/ini.tm
@@ -9,10 +9,10 @@ _HELP := "
$_USAGE
"
-func parse_ini(path:Path -> {Text,{Text,Text}}):
+func parse_ini(path:Path -> {Text={Text=Text}}):
text := path:read() or exit("Could not read INI file: $\[31;1]$(path)$\[]")
- sections := @{:Text,@{Text,Text}}
- current_section := @{:Text,Text}
+ sections := @{:Text=@{Text=Text}}
+ current_section := @{:Text=Text}
# Line wraps:
text = text:replace_pattern($Pat/\{1 nl}{0+space}/, " ")
@@ -22,7 +22,7 @@ func parse_ini(path:Path -> {Text,{Text,Text}}):
skip if line:starts_with(";") or line:starts_with("#")
if line:matches_pattern($Pat/[?]/):
section_name := line:replace($Pat/[?]/, "\1"):trim():lower()
- current_section = @{:Text,Text}
+ current_section = @{:Text=Text}
sections[section_name] = current_section
else if line:matches_pattern($Pat/{..}={..}/):
key := line:replace_pattern($Pat/{..}={..}/, "\1"):trim():lower()
diff --git a/examples/learnxiny.tm b/examples/learnxiny.tm
index 00c7e94a..a394e581 100644
--- a/examples/learnxiny.tm
+++ b/examples/learnxiny.tm
@@ -123,7 +123,7 @@ func main():
= 0
# Empty tables require specifying the key and value types:
- empty_table := {:Text,Int}
+ empty_table := {:Text=Int}
# Tables can be iterated over either by key or key,value:
for key in table:
@@ -243,7 +243,7 @@ func takes_many_types(
floating_point_number:Num,
text_aka_string:Text,
array_of_ints:[Int],
- table_of_text_to_bools:{Text,Bool},
+ table_of_text_to_bools:{Text=Bool},
pointer_to_mutable_array_of_ints:@[Int],
optional_int:Int?,
function_from_int_to_text:func(x:Int -> Text),
diff --git a/examples/patterns/patterns.tm b/examples/patterns/patterns.tm
index 6afcdc25..15226848 100644
--- a/examples/patterns/patterns.tm
+++ b/examples/patterns/patterns.tm
@@ -19,7 +19,7 @@ extend Text:
func replace_pattern(text:Text, pattern:Pat, replacement:Text, backref="@", recursive=yes -> Text):
return inline C : Text { Pattern$replace(_$text, _$pattern, _$replacement, _$backref, _$recursive); }
- func translate_patterns(text:Text, replacements:{Pat,Text}, backref="@", recursive=yes -> Text):
+ func translate_patterns(text:Text, replacements:{Pat=Text}, backref="@", recursive=yes -> Text):
return inline C : Text { Pattern$replace_all(_$text, _$replacements, _$backref, _$recursive); }
func has_pattern(text:Text, pattern:Pat -> Bool):