Little update

This commit is contained in:
Aoran Zeng 2025-07-16 01:45:09 +08:00
parent c4d0d1eb0e
commit c3657b44ef
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98

View File

@ -13,13 +13,13 @@
unit module Parser;
#| Bool Boolean
my enum ConfigValueType <String Mode Boolean>;
my enum ConfigItemValueType <String Mode Boolean>;
#|
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;