diff --git a/tool/rawstr4c/lib/Parser.rakumod b/tool/rawstr4c/lib/Parser.rakumod index 084960b..816709a 100644 --- a/tool/rawstr4c/lib/Parser.rakumod +++ b/tool/rawstr4c/lib/Parser.rakumod @@ -13,13 +13,13 @@ unit module Parser; #| 不能用 Bool,只能用 Boolean -my enum ConfigValueType ; +my enum ConfigItemValueType ; #| 配置项的值 -my class ConfigValue { - has ConfigValueType $.type; - has Str $.raw-value; - has Any $.parsed-value; +my class ConfigItemValue { + has ConfigItemValueType $.type; + has Str $.raw-value; + has Any $.parsed-value; method new($raw-text) { my $type; @@ -77,32 +77,32 @@ my class ConfigValue { #| 包含所有 config items 的容器 my class Config { - has %.items; + has %!items; # 如果非要在程序内部中调用,而不是直接从 Markdown 文件中读取出来 # 一定要记得 $raw-value 用的是 rawstr4c 的语法!也就是说,这里一定是一个字符串 method set($k, $raw-value) { - %.items{$k} = ConfigValue.new($raw-value); + %!items{$k} = ConfigItemValue.new($raw-value); } method get($k, $default = Nil) { - return %.items{$k} // ($default ?? ConfigValue.new($default) !! ConfigValue.new('')); + return %!items{$k} // ($default ?? ConfigItemValue.new($default) !! ConfigItemValue.new('')); } method exist($k) { - return %.items{$k}:exists; + return %!items{$k}:exists; } # 配置项名称 # @danger: 把这个函数命名为 items,会让我的机器蓝屏..... method keys() { - return %.items.keys; + return %!items.keys; } } #| 表示一个 section -class Section { +my class Section { has Str $.title; has Int $.level;