aboutsummaryrefslogtreecommitdiff
path: root/examples/ini
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-11-30 15:50:54 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-11-30 15:50:54 -0500
commit40c33987fa0a91a8525d960f8494ca9ddf12806d (patch)
treefa89233cbd7096de735348b39704e1ddb97dfe0c /examples/ini
parentf3fc7558bb425c4bd59b55527d2fafaa744fe0aa (diff)
Bring back `table[key]` syntax
Diffstat (limited to 'examples/ini')
-rw-r--r--examples/ini/ini.tm8
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/ini/ini.tm b/examples/ini/ini.tm
index 5952bb00..9575b9fd 100644
--- a/examples/ini/ini.tm
+++ b/examples/ini/ini.tm
@@ -20,11 +20,11 @@ func parse_ini(path:Path -> {Text:{Text:Text}}):
if line:matches($/[?]/):
section_name := line:replace($/[?]/, "\1"):trim():lower()
current_section = @{:Text:Text}
- sections:set(section_name, current_section)
+ sections[section_name] = current_section
else if line:matches($/{..}={..}/):
key := line:replace($/{..}={..}/, "\1"):trim():lower()
value := line:replace($/{..}={..}/, "\2"):trim()
- current_section:set(key, value)
+ current_section[key] = value
return {k:v[] for k,v in sections[]}
@@ -42,7 +42,7 @@ func main(path:Path, key:Text?):
return
section := keys[1]:lower()
- section_data := data:get(section) or exit("
+ section_data := data[section] or exit("
Invalid section name: $\[31;1]$section$\[]
Valid names: $\[1]$(", ":join([k:quoted() for k in data.keys]))$\[]
")
@@ -51,7 +51,7 @@ func main(path:Path, key:Text?):
return
section_key := keys[2]:lower()
- value := section_data:get(section_key) or exit("
+ value := section_data[section_key] or exit("
Invalid key: $\[31;1]$section_key$\[]
Valid keys: $\[1]$(", ":join([s:quoted() for s in section_data.keys]))$\[]
")