From 40c33987fa0a91a8525d960f8494ca9ddf12806d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sat, 30 Nov 2024 15:50:54 -0500 Subject: Bring back `table[key]` syntax --- examples/ini/ini.tm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples/ini') 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]))$\[] ") -- cgit v1.2.3