12
12
return bless $data,$package;
15
# TODO: access readonly (writeprotect)
15
# TODO: entry name validation
16
16
# (temporary dictionary can be satisfied by using temporary instance of this)
47
47
$self->push(undef, $script);
49
49
while($string !~ /^[ \t\n]*$/){
50
$string =~ s/^[ \t\n]*([^ \t]+?)[ \t]*://s;
50
$string =~ s/^[ \t\n]*(.+?)[ \t]*://s;
51
51
my ($entry_names_str) = $1;
52
die 'dict error' unless defined $entry_names_str;
53
die 'invalid entry name' unless $entry_names_str =~ /^[\w\d_.?@]+$/; # TODO: validation
52
die 'dict error',"[$1]",$string unless defined $entry_names_str;
54
53
my @entry_names = split /[ \t]*,[ \t]*/,$entry_names_str;
55
54
while($string !~ /^[ \t]*(?:\n|$)/){
56
55
$string =~ s/^[ \t]*,//;
70
$entryvalue = Kawari::Dict::Value::Analize->new();
71
my $kisvalue = Kawari::Dict::Value::Analize->new('cmd');
76
#print STDERR "\n_=$_\n";###
77
if(/^[ \t]*(?:#.*)?$/){ # コメント・空白行をスキップ
82
}elsif($1 eq 'endrem'){
83
$flag{comment} = undef;
85
}elsif($flag{comment}){
88
die 'Unmatch blacket.'if !$noblacketend;
91
die 'Unmatch blacket.'if !$noblacketend;
94
die 'Unmatch blacket.'if !$noblacketend;
97
if($mode->[-1] eq 'kis'){
98
$noblacketend = $kisvalue->analize($_);
101
if(!$entryvalue->stackdepth()){ # 括弧の外
102
($key,$value) = /^[ \t]*(.+?)[ \t]*:[ \t]*(.*)[ \t]*$/; # エントリのキーと値を分割
103
die "Wrong format." unless defined $key;
104
$keylist = [split /[ \t]*,[ \t]*/,$key]; # キーの分割
105
$entryvalue = Kawari::Dict::Value::Analize->new();
109
#print STDERR " keylist=@{[join '/',@$keylist]}\n";###
110
#print STDERR " value =$value\n";###
111
$noblacketend = $entryvalue->analize($value);
113
$self->pushentry($keylist,$entryvalue->value()->valuetree());
114
#push @{$self->{$_}},$entryvalue->getvalue() for @$keylist;
116
#print STDERR Data::Dumper->Dump($entryvalue->{value}->{valuetree});###
122
if($kisvalue->stackdepth() || $entryvalue->stackdepth()){
123
die "Unmatch bracket.";
125
push @{$self->{'/'}},Kawari::Dict::Value->new('readonly',$kisvalue->value());
126
#print STDERR "Fin.\n";###
127
#print "$_:",(join " | ",@{$self->{dic}->{$_}}),"\n" for sort keys %{$self->{dic}};
128
#print STDERR "$_:",(join "",map {$_->{bra}.$_->{value}.$self->{cket}->{$_->{bra}}->{join}} @{$self->{dic}->{$_}->[0]}),"\n" for sort keys %{$self->{dic}};