line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RDF::Notation3; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.005_62; |
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
76
|
|
5
|
|
|
|
|
|
|
#use warnings; |
6
|
2
|
|
|
2
|
|
13
|
use vars qw($VERSION); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
93
|
|
7
|
2
|
|
|
2
|
|
1676
|
use File::Spec::Functions (); |
|
2
|
|
|
|
|
1790
|
|
|
2
|
|
|
|
|
50
|
|
8
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
152
|
|
9
|
2
|
|
|
2
|
|
1074
|
use RDF::Notation3::ReaderFile; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
54
|
|
10
|
2
|
|
|
2
|
|
1006
|
use RDF::Notation3::ReaderString; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9503
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
$VERSION = '0.91'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
############################################################ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
4
|
|
|
4
|
0
|
1438
|
my ($class) = @_; |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
25
|
my $self = { |
20
|
|
|
|
|
|
|
ansuri => '#', |
21
|
|
|
|
|
|
|
quantif => 1, |
22
|
|
|
|
|
|
|
nIDpref => '_:a', # this fits to RDF:Core prefix for nodeID |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
11
|
bless $self, $class; |
26
|
4
|
|
|
|
|
12
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub parse_file { |
31
|
10
|
|
|
10
|
0
|
15
|
my ($self, $path) = @_; |
32
|
|
|
|
|
|
|
|
33
|
10
|
|
|
|
|
67
|
$self->_define; |
34
|
|
|
|
|
|
|
|
35
|
10
|
|
|
|
|
13
|
my $fh; |
36
|
10
|
50
|
|
|
|
22
|
if (ref $path eq 'IO::File') { |
37
|
0
|
|
|
|
|
0
|
$fh = $path; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} else { |
40
|
10
|
50
|
|
|
|
596
|
open(FILE, "$path") or $self->_do_error(2, $path); |
41
|
10
|
|
|
|
|
34
|
$fh = *FILE; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
10
|
|
|
|
|
46
|
my $t = new RDF::Notation3::ReaderFile($fh); |
45
|
10
|
|
|
|
|
25
|
$self->{reader} = $t; |
46
|
|
|
|
|
|
|
|
47
|
10
|
|
|
|
|
52
|
$self->_document; |
48
|
|
|
|
|
|
|
|
49
|
10
|
|
|
|
|
160
|
close (FILE); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub parse_string { |
54
|
0
|
|
|
0
|
0
|
0
|
my ($self, $str) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
$self->_define; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
0
|
my $t = new RDF::Notation3::ReaderString($str); |
59
|
0
|
|
|
|
|
0
|
$self->{reader} = $t; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
$self->_document; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub anonymous_ns_uri { |
66
|
0
|
|
|
0
|
0
|
0
|
my ($self, $uri) = @_; |
67
|
0
|
0
|
|
|
|
0
|
if (@_ > 1) { |
68
|
0
|
|
|
|
|
0
|
$self->{ansuri} = $uri; |
69
|
|
|
|
|
|
|
} else { |
70
|
0
|
|
|
|
|
0
|
return $self->{ansuri}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub quantification { |
75
|
1
|
|
|
1
|
0
|
260
|
my ($self, $val) = @_; |
76
|
1
|
50
|
|
|
|
5
|
if (@_ > 1) { |
77
|
1
|
50
|
33
|
|
|
9
|
$self->_do_error(4, $val) |
78
|
|
|
|
|
|
|
unless $val == 1 || $val == 0; |
79
|
1
|
|
|
|
|
5
|
$self->{quantif} = $val; |
80
|
|
|
|
|
|
|
} else { |
81
|
0
|
|
|
|
|
0
|
return $self->{quantif}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _define { |
87
|
10
|
|
|
10
|
|
14
|
my ($self) = @_; |
88
|
|
|
|
|
|
|
|
89
|
10
|
|
|
|
|
18
|
$self->{ns} = {}; |
90
|
10
|
|
|
|
|
34
|
$self->{context} = '<>'; |
91
|
10
|
|
|
|
|
14
|
$self->{gid} = 1; |
92
|
10
|
|
|
|
|
15
|
$self->{cid} = 1; |
93
|
10
|
|
|
|
|
61
|
$self->{hardns} = { |
94
|
|
|
|
|
|
|
rdf => ['rdf','http://www.w3.org/1999/02/22-rdf-syntax-ns#'], |
95
|
|
|
|
|
|
|
daml => ['daml','http://www.daml.org/2001/03/daml+oil#'], |
96
|
|
|
|
|
|
|
log => ['log','http://www.w3.org/2000/10/swap/log.n3#'], |
97
|
|
|
|
|
|
|
}; |
98
|
10
|
|
|
|
|
51
|
$self->{keywords} = []; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _document { |
103
|
10
|
|
|
10
|
|
13
|
my ($self) = @_; |
104
|
10
|
|
|
|
|
36
|
my $next = $self->{reader}->try; |
105
|
|
|
|
|
|
|
#print ">doc starts: $next\n"; |
106
|
10
|
50
|
|
|
|
31
|
if ($next ne ' EOF ') { |
107
|
10
|
|
|
|
|
32
|
$self->_statement_list; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
#print ">end\n"; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub _statement_list { |
114
|
22
|
|
|
22
|
|
30
|
my ($self) = @_; |
115
|
22
|
|
|
|
|
46
|
my $next = $self->_eat_EOLs; |
116
|
|
|
|
|
|
|
#print ">statement list: $next\n"; |
117
|
|
|
|
|
|
|
|
118
|
22
|
|
|
|
|
52
|
while ($next ne ' EOF ') { |
119
|
107
|
100
|
|
|
|
387
|
if ($next =~ /^(?:|#.*)$/) { |
|
|
100
|
|
|
|
|
|
120
|
2
|
|
|
|
|
20
|
$self->_space; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} elsif ($next =~ /^}/) { |
123
|
|
|
|
|
|
|
#print ">end of nested statement list: $next\n"; |
124
|
12
|
|
|
|
|
23
|
last; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} else { |
127
|
93
|
|
|
|
|
212
|
$self->_statement; |
128
|
|
|
|
|
|
|
} |
129
|
95
|
|
|
|
|
208
|
$next = $self->_eat_EOLs; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
#print ">end of statement list: $next\n"; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub _space { |
136
|
2
|
|
|
2
|
|
2
|
my ($self) = @_; |
137
|
|
|
|
|
|
|
#print ">space: "; |
138
|
|
|
|
|
|
|
|
139
|
2
|
|
|
|
|
8
|
my $tk = $self->{reader}->get; |
140
|
|
|
|
|
|
|
# comment or empty string |
141
|
2
|
|
|
|
|
7
|
while ($tk ne ' EOL ') { |
142
|
|
|
|
|
|
|
#print ">$tk "; |
143
|
10
|
|
|
|
|
23
|
$tk = $self->{reader}->get; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
#print ">\n"; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub _statement { |
150
|
129
|
|
|
129
|
|
188
|
my ($self, $subject) = @_; |
151
|
129
|
|
|
|
|
398
|
my $next = $self->{reader}->try; |
152
|
|
|
|
|
|
|
#print ">statement starts: $next\n"; |
153
|
|
|
|
|
|
|
|
154
|
129
|
100
|
|
|
|
478
|
if ($next =~ /^\@prefix|\@keywords|bind$/) { |
155
|
34
|
|
|
|
|
89
|
$self->_directive; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
} else { |
158
|
95
|
100
|
|
|
|
266
|
$subject = $self->_node unless $subject; |
159
|
|
|
|
|
|
|
#print ">subject: $subject\n"; |
160
|
|
|
|
|
|
|
|
161
|
95
|
|
|
|
|
164
|
my $properties = []; |
162
|
95
|
|
|
|
|
230
|
$self->_property_list($properties); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
#print ">CONTEXT: $self->{context}\n"; |
165
|
|
|
|
|
|
|
#print ">SUBJECT: $subject\n"; |
166
|
|
|
|
|
|
|
#print ">PROPERTY: void\n" unless @$properties; |
167
|
|
|
|
|
|
|
#foreach (@$properties) { # comment/uncomment by hand |
168
|
|
|
|
|
|
|
#print ">PROPERTY: ", join('-', @$_), "\n"; |
169
|
|
|
|
|
|
|
#} |
170
|
|
|
|
|
|
|
|
171
|
95
|
50
|
|
|
|
422
|
$self->_process_statement($subject, $properties) if @$properties; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
# next step |
174
|
129
|
|
|
|
|
335
|
$next = $self->_eat_EOLs; |
175
|
129
|
100
|
|
|
|
490
|
if ($next eq '.') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
176
|
93
|
|
|
|
|
244
|
$self->{reader}->get; |
177
|
|
|
|
|
|
|
} elsif ($next =~ /^\.(.*)$/) { |
178
|
0
|
|
|
|
|
0
|
$self->{reader}->get; |
179
|
0
|
|
|
|
|
0
|
unshift @{$self->{reader}->{tokens}}, $1; |
|
0
|
|
|
|
|
0
|
|
180
|
|
|
|
|
|
|
} elsif ($next =~ /^(?:\]|\)|\})/) { |
181
|
|
|
|
|
|
|
} else { |
182
|
0
|
|
|
|
|
0
|
$self->_do_error(115,$next); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub _node { |
188
|
339
|
|
|
339
|
|
376
|
my ($self) = @_; |
189
|
339
|
|
|
|
|
604
|
my $next = $self->_eat_EOLs; |
190
|
|
|
|
|
|
|
#print ">node: $next\n"; |
191
|
|
|
|
|
|
|
|
192
|
339
|
100
|
33
|
|
|
5017
|
if ($next =~ /^[\[\{\(]/) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
193
|
|
|
|
|
|
|
#print ">node is anonnode\n"; |
194
|
51
|
|
|
|
|
154
|
return $self->_anonymous_node; |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
} elsif ($next eq 'this') { |
197
|
|
|
|
|
|
|
#print ">this\n"; |
198
|
6
|
|
|
|
|
16
|
$self->{reader}->get; |
199
|
6
|
|
|
|
|
19
|
return "$self->{context}"; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
} elsif ($next =~ /^(<[^>]*>|^(?:[_a-zA-Z]\w*)?:[_a-zA-Z][_\w]*)(.*)$/) { |
202
|
|
|
|
|
|
|
#print ">node is uri_ref2: $next\n"; |
203
|
|
|
|
|
|
|
|
204
|
260
|
100
|
|
|
|
636
|
if ($2) { |
205
|
3
|
|
|
|
|
11
|
$self->{reader}->get; |
206
|
3
|
|
|
|
|
5
|
unshift @{$self->{reader}->{tokens}}, $2; |
|
3
|
|
|
|
|
9
|
|
207
|
3
|
|
|
|
|
6
|
unshift @{$self->{reader}->{tokens}}, $1; |
|
3
|
|
|
|
|
8
|
|
208
|
|
|
|
|
|
|
#print ">cleaned uri_ref2: $1\n"; |
209
|
|
|
|
|
|
|
} |
210
|
260
|
|
|
|
|
677
|
return $self->_uri_ref2; |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
} elsif ($self->{keywords}[0] && ($next =~ /^(^[_a-zA-Z][_\w]*)(.*)$/)) { |
213
|
|
|
|
|
|
|
#print ">node is uri_ref_kw: $next\n"; |
214
|
|
|
|
|
|
|
|
215
|
22
|
|
|
|
|
67
|
$self->{reader}->get; |
216
|
22
|
50
|
|
|
|
67
|
unshift @{$self->{reader}->{tokens}}, $2 if $2; |
|
0
|
|
|
|
|
0
|
|
217
|
22
|
|
|
|
|
31
|
unshift @{$self->{reader}->{tokens}}, ':' . $1; |
|
22
|
|
|
|
|
80
|
|
218
|
|
|
|
|
|
|
#print ">cleaned uri_ref2: $1\n"; |
219
|
22
|
|
|
|
|
54
|
return $self->_uri_ref2; |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
} else { |
222
|
|
|
|
|
|
|
#print ">unknown node: $next\n"; |
223
|
0
|
|
|
|
|
0
|
$self->_do_error(116,$next); |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub _directive { |
229
|
34
|
|
|
34
|
|
39
|
my ($self) = @_; |
230
|
34
|
|
|
|
|
91
|
my $tk = $self->{reader}->get; |
231
|
|
|
|
|
|
|
#print ">directive: $tk\n"; |
232
|
|
|
|
|
|
|
|
233
|
34
|
100
|
|
|
|
84
|
if ($tk eq '@prefix') { |
|
|
50
|
|
|
|
|
|
234
|
33
|
|
|
|
|
78
|
my $tk = $self->{reader}->get; |
235
|
33
|
50
|
|
|
|
144
|
if ($tk =~ /^([_a-zA-Z]\w*)?:$/) { |
236
|
33
|
|
|
|
|
62
|
my $pref = $1; |
237
|
|
|
|
|
|
|
#print ">nprefix: $pref\n" if $pref; |
238
|
|
|
|
|
|
|
|
239
|
33
|
|
|
|
|
73
|
my $ns_uri = $self->_uri_ref2; |
240
|
33
|
|
|
|
|
138
|
$ns_uri =~ s/^<(.*)>$/$1/; |
241
|
|
|
|
|
|
|
|
242
|
33
|
100
|
|
|
|
89
|
if ($pref) { |
243
|
26
|
|
|
|
|
117
|
$self->{ns}->{$self->{context}}->{$pref} = $ns_uri; |
244
|
|
|
|
|
|
|
} else { |
245
|
7
|
|
|
|
|
30
|
$self->{ns}->{$self->{context}}->{''} = $ns_uri; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
} else { |
248
|
0
|
|
|
|
|
0
|
$self->_do_error(102,$tk); |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
} elsif ($tk eq '@keywords') { |
252
|
1
|
|
|
|
|
5
|
my $kw = $self->{reader}->get; |
253
|
1
|
|
|
|
|
8
|
while ($kw =~ /,$/) { |
254
|
2
|
|
|
|
|
7
|
$kw =~ s/,$//; |
255
|
2
|
|
|
|
|
3
|
push @{$self->{keywords}}, $kw; |
|
2
|
|
|
|
|
85
|
|
256
|
2
|
|
|
|
|
10
|
$kw = $self->{reader}->get; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
1
|
50
|
|
|
|
7
|
if ($kw =~ /^(.+)\.$/) { |
260
|
1
|
|
|
|
|
2
|
push @{$self->{keywords}}, $1; |
|
1
|
|
|
|
|
4
|
|
261
|
1
|
|
|
|
|
2
|
unshift @{$self->{reader}{tokens}}, '.'; |
|
1
|
|
|
|
|
5
|
|
262
|
|
|
|
|
|
|
} else { |
263
|
0
|
|
|
|
|
0
|
$self->_do_error(117,$tk); |
264
|
|
|
|
|
|
|
} |
265
|
|
|
|
|
|
|
#print ">keywords: ", join('|', @{$self->{keywords}}), "\n"; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
} else { |
268
|
0
|
|
|
|
|
0
|
$self->_do_error(101,$tk); |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
sub _uri_ref2 { |
274
|
315
|
|
|
315
|
|
404
|
my ($self) = @_; |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
# possible end of statement, a simple . check is done |
277
|
315
|
|
|
|
|
870
|
my $next = $self->{reader}->try; |
278
|
315
|
100
|
|
|
|
800
|
if ($next =~ /^(.+)\.$/) { |
279
|
8
|
|
|
|
|
33
|
$self->{reader}->{tokens}->[0] = '.'; |
280
|
8
|
|
|
|
|
11
|
unshift @{$self->{reader}->{tokens}}, $1; |
|
8
|
|
|
|
|
25
|
|
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
|
283
|
315
|
|
|
|
|
795
|
my $tk = $self->{reader}->get; |
284
|
|
|
|
|
|
|
#print ">uri_ref2: $tk\n"; |
285
|
|
|
|
|
|
|
|
286
|
315
|
100
|
|
|
|
1356
|
if ($tk =~ /^<[^>]*>$/) { |
|
|
50
|
|
|
|
|
|
287
|
|
|
|
|
|
|
#print ">URI\n"; |
288
|
127
|
|
|
|
|
387
|
return $tk; |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
} elsif ($tk =~ /^([_a-zA-Z]\w*)?:[a-zA-Z]\w*$/) { |
291
|
|
|
|
|
|
|
#print ">qname ($1:)\n" if $1; |
292
|
|
|
|
|
|
|
|
293
|
188
|
|
|
|
|
222
|
my $pref = ''; |
294
|
188
|
100
|
|
|
|
484
|
$pref = $1 if $1; |
295
|
188
|
50
|
|
|
|
348
|
if ($pref eq '_') { # workaround to parse N-Triples |
296
|
0
|
0
|
|
|
|
0
|
$self->{ns}->{$self->{context}}->{_} = $self->{ansuri} |
297
|
|
|
|
|
|
|
unless $self->{ns}->{$self->{context}}->{_}; |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
# Identifier demunging |
301
|
188
|
100
|
|
|
|
407
|
$tk = _unesc_qname($tk) if $tk =~ /_/; |
302
|
188
|
|
|
|
|
572
|
return $tk; |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
} else { |
305
|
0
|
|
|
|
|
0
|
$self->_do_error(103,$tk); |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
} |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
sub _property_list { |
311
|
140
|
|
|
140
|
|
169
|
my ($self, $properties) = @_; |
312
|
140
|
|
|
|
|
241
|
my $next = $self->_eat_EOLs; |
313
|
|
|
|
|
|
|
#print ">property list: $next\n"; |
314
|
|
|
|
|
|
|
|
315
|
140
|
|
|
|
|
293
|
$next = $self->_check_inline_comment($next); |
316
|
|
|
|
|
|
|
|
317
|
140
|
50
|
|
|
|
416
|
if ($next =~ /^:-/) { |
|
|
50
|
|
|
|
|
|
318
|
|
|
|
|
|
|
#print ">anonnode\n"; |
319
|
|
|
|
|
|
|
# TBD |
320
|
0
|
|
|
|
|
0
|
$self->_do_error(199, $next); |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
} elsif ($next =~ /^\./) { |
323
|
|
|
|
|
|
|
#print ">void prop_list\n"; |
324
|
|
|
|
|
|
|
# TBD |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
} else { |
327
|
|
|
|
|
|
|
#print ">prop_list with verb\n"; |
328
|
140
|
|
|
|
|
260
|
my $property = $self->_verb; |
329
|
|
|
|
|
|
|
#print ">property is back: $property\n"; |
330
|
|
|
|
|
|
|
|
331
|
140
|
|
|
|
|
229
|
my $objects = []; |
332
|
140
|
|
|
|
|
292
|
$self->_object_list($objects); |
333
|
140
|
|
|
|
|
267
|
unshift @$objects, $property; |
334
|
140
|
50
|
33
|
|
|
667
|
unshift @$objects, 'i' if ($next eq 'is' or $next eq '<-'); |
335
|
|
|
|
|
|
|
#print ">inverse mode\n" if ($next eq 'is' or $next eq '<-'); |
336
|
140
|
|
|
|
|
262
|
push @$properties, $objects; |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
# next step |
339
|
140
|
|
|
|
|
247
|
$next = $self->_eat_EOLs; |
340
|
140
|
100
|
|
|
|
378
|
if ($next eq ';') { |
341
|
45
|
|
|
|
|
121
|
$self->{reader}->get; |
342
|
45
|
|
|
|
|
131
|
$self->_property_list($properties); |
343
|
|
|
|
|
|
|
} |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
sub _verb { |
348
|
140
|
|
|
140
|
|
151
|
my ($self) = @_; |
349
|
140
|
|
|
|
|
562
|
my $next = $self->{reader}->try; |
350
|
|
|
|
|
|
|
#print ">verb: $next\n"; |
351
|
|
|
|
|
|
|
|
352
|
140
|
50
|
|
|
|
632
|
if ($next eq 'has') { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
353
|
0
|
|
|
|
|
0
|
$self->{reader}->get; |
354
|
0
|
|
|
|
|
0
|
return $self->_node; |
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
} elsif ($next eq '>-') { |
357
|
0
|
|
|
|
|
0
|
$self->{reader}->get; |
358
|
0
|
|
|
|
|
0
|
my $node = $self->_node; |
359
|
0
|
|
|
|
|
0
|
my $tk = $self->{reader}->get; |
360
|
0
|
0
|
|
|
|
0
|
$self->_do_error(104,$tk) unless $tk eq '->'; |
361
|
0
|
|
|
|
|
0
|
return $node; |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
} elsif ($next eq 'is') { |
364
|
0
|
|
|
|
|
0
|
$self->{reader}->get; |
365
|
0
|
|
|
|
|
0
|
my $node = $self->_node; |
366
|
0
|
|
|
|
|
0
|
my $tk = $self->{reader}->get; |
367
|
0
|
0
|
|
|
|
0
|
$self->_do_error(109,$tk) unless $tk eq 'of'; |
368
|
0
|
|
|
|
|
0
|
return $node; |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
} elsif ($next eq '<-') { |
371
|
0
|
|
|
|
|
0
|
$self->{reader}->get; |
372
|
0
|
|
|
|
|
0
|
my $node = $self->_node; |
373
|
0
|
|
|
|
|
0
|
my $tk = $self->{reader}->get; |
374
|
0
|
0
|
|
|
|
0
|
$self->_do_error(110,$tk) unless $tk eq '-<'; |
375
|
0
|
|
|
|
|
0
|
return $node; |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
} elsif ($next eq 'a') { |
378
|
14
|
|
|
|
|
39
|
$self->{reader}->get; |
379
|
14
|
|
|
|
|
38
|
return $self->_built_in_verb('rdf','type'); |
380
|
|
|
|
|
|
|
# return '' |
381
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
} elsif ($next =~ /^=(.*)/) { |
383
|
0
|
|
|
|
|
0
|
$self->{reader}->get; |
384
|
0
|
0
|
|
|
|
0
|
unshift @{$self->{reader}->{tokens}}, $1 if $1; |
|
0
|
|
|
|
|
0
|
|
385
|
0
|
|
|
|
|
0
|
return $self->_built_in_verb('daml','equivalentTo'); |
386
|
|
|
|
|
|
|
# return ''; |
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
} else { |
389
|
|
|
|
|
|
|
#print ">property: $next\n"; |
390
|
126
|
|
|
|
|
267
|
return $self->_node; |
391
|
|
|
|
|
|
|
} |
392
|
|
|
|
|
|
|
} |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
sub _object_list { |
396
|
146
|
|
|
146
|
|
197
|
my ($self, $objects) = @_; |
397
|
146
|
|
|
|
|
243
|
my $next = $self->_eat_EOLs; |
398
|
|
|
|
|
|
|
#print ">object list: $next\n"; |
399
|
|
|
|
|
|
|
|
400
|
146
|
|
|
|
|
303
|
$next = $self->_check_inline_comment($next); |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
# possible end of entity, check for sticked next char is done |
403
|
146
|
|
|
|
|
700
|
while ($next =~ /^([^"]+)([,;\.\}\]\)])$/) { |
404
|
22
|
|
|
|
|
66
|
$self->{reader}->{tokens}->[0] = $2; |
405
|
22
|
|
|
|
|
62
|
unshift @{$self->{reader}->{tokens}}, $1; |
|
22
|
|
|
|
|
55
|
|
406
|
22
|
|
|
|
|
115
|
$next = $1; |
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
|
409
|
146
|
|
|
|
|
298
|
my $obj = $self->_object; |
410
|
|
|
|
|
|
|
#print ">object is back: $obj\n"; |
411
|
146
|
|
|
|
|
283
|
push @$objects, $obj; |
412
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
# next step |
414
|
146
|
|
|
|
|
307
|
$next = $self->_eat_EOLs; |
415
|
146
|
100
|
|
|
|
382
|
if ($next eq ',') { |
416
|
6
|
|
|
|
|
17
|
$self->{reader}->get; |
417
|
6
|
|
|
|
|
16
|
$self->_object_list($objects); |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
} |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
sub _object { |
423
|
177
|
|
|
177
|
|
196
|
my ($self) = @_; |
424
|
177
|
|
|
|
|
275
|
my $next = $self->_eat_EOLs; |
425
|
|
|
|
|
|
|
#print ">object: $next:\n"; |
426
|
|
|
|
|
|
|
|
427
|
177
|
100
|
|
|
|
527
|
if ($next =~ /^("(?:\\"|[^\"])*")([\.;,\]\}\)])*$/) { |
428
|
|
|
|
|
|
|
#print ">complete string1: $next\n"; |
429
|
23
|
|
|
|
|
75
|
my $tk = $self->{reader}->get; |
430
|
23
|
50
|
|
|
|
64
|
unshift @{$self->{reader}->{tokens}}, $2 if $2; |
|
0
|
|
|
|
|
0
|
|
431
|
23
|
|
|
|
|
74
|
return $self->_unesc_string($1); |
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
} else { |
434
|
|
|
|
|
|
|
#print ">object is node: $next\n"; |
435
|
154
|
|
|
|
|
304
|
$self->_node; |
436
|
|
|
|
|
|
|
} |
437
|
|
|
|
|
|
|
} |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
sub _anonymous_node { |
441
|
68
|
|
|
68
|
|
102
|
my ($self) = @_; |
442
|
68
|
|
|
|
|
178
|
my $next = $self->{reader}->try; |
443
|
68
|
|
|
|
|
213
|
$next =~ /^([\[\{\(])(.*)$/; |
444
|
|
|
|
|
|
|
#print ">anonnode1: $1\n"; |
445
|
|
|
|
|
|
|
#print ">anonnode2: $2\n"; |
446
|
|
|
|
|
|
|
|
447
|
68
|
|
|
|
|
178
|
$self->{reader}->get; |
448
|
68
|
100
|
|
|
|
196
|
unshift @{$self->{reader}->{tokens}}, $2 if $2; |
|
1
|
|
|
|
|
4
|
|
449
|
|
|
|
|
|
|
|
450
|
68
|
100
|
|
|
|
199
|
if ($1 eq '[') { |
|
|
100
|
|
|
|
|
|
451
|
|
|
|
|
|
|
#print ">anonnode: []\n"; |
452
|
36
|
|
|
|
|
102
|
my $genid = "<$self->{ansuri}g_$self->{gid}>"; |
453
|
36
|
|
|
|
|
46
|
$self->{gid}++; |
454
|
|
|
|
|
|
|
|
455
|
36
|
|
|
|
|
70
|
$next = $self->_eat_EOLs; |
456
|
36
|
50
|
|
|
|
83
|
if ($next =~ /^\](.)*$/) { |
457
|
0
|
|
|
|
|
0
|
$self->_exist_quantif($genid); |
458
|
|
|
|
|
|
|
} else { |
459
|
36
|
|
|
|
|
80
|
$self->_exist_quantif($genid); |
460
|
36
|
|
|
|
|
96
|
$self->_statement($genid); |
461
|
|
|
|
|
|
|
} |
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
# next step |
464
|
36
|
|
|
|
|
80
|
$next = $self->_eat_EOLs; |
465
|
36
|
|
|
|
|
147
|
my $tk = $self->{reader}->get; |
466
|
36
|
100
|
|
|
|
136
|
if ($tk =~ /^\](.+)$/) { |
|
|
50
|
|
|
|
|
|
467
|
1
|
|
|
|
|
2
|
unshift @{$self->{reader}->{tokens}}, $1; |
|
1
|
|
|
|
|
3
|
|
468
|
|
|
|
|
|
|
} elsif ($tk ne ']') { |
469
|
0
|
|
|
|
|
0
|
$self->_do_error(107, $tk); |
470
|
|
|
|
|
|
|
} |
471
|
36
|
|
|
|
|
121
|
return $genid; |
472
|
|
|
|
|
|
|
|
473
|
|
|
|
|
|
|
} elsif ($1 eq '{') { |
474
|
|
|
|
|
|
|
#print ">anonnode: {}\n"; |
475
|
12
|
|
|
|
|
36
|
my $genid = "<$self->{ansuri}c_$self->{cid}>"; |
476
|
12
|
|
|
|
|
19
|
$self->{cid}++; |
477
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
# ns mapping is passed to inner context |
479
|
12
|
|
|
|
|
29
|
$self->{ns}->{$genid} = {}; |
480
|
12
|
|
|
|
|
15
|
foreach (keys %{$self->{ns}->{$self->{context}}}) { |
|
12
|
|
|
|
|
195
|
|
481
|
54
|
|
|
|
|
243
|
$self->{ns}->{$genid}->{$_} = |
482
|
|
|
|
|
|
|
$self->{ns}->{$self->{context}}->{$_}; |
483
|
|
|
|
|
|
|
#print ">prefix '$_' passed to inner context\n"; |
484
|
|
|
|
|
|
|
} |
485
|
|
|
|
|
|
|
|
486
|
12
|
|
|
|
|
27
|
my $parent_context = $self->{context}; |
487
|
12
|
|
|
|
|
18
|
$self->{context} = $genid; |
488
|
12
|
|
|
|
|
28
|
$self->_exist_quantif($genid); # quantifying the new context |
489
|
12
|
|
|
|
|
43
|
$self->_statement_list; # parsing nested statements |
490
|
12
|
|
|
|
|
17
|
$self->{context} = $parent_context; |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
# next step |
493
|
12
|
|
|
|
|
26
|
$self->_eat_EOLs; |
494
|
12
|
|
|
|
|
39
|
my $tk = $self->{reader}->get; |
495
|
|
|
|
|
|
|
#print ">next token: $tk\n"; |
496
|
12
|
50
|
|
|
|
46
|
if ($tk =~ /^\}([,;\.\]\}\)])?$/) { |
497
|
12
|
100
|
|
|
|
33
|
unshift @{$self->{reader}->{tokens}}, $1 if $1; |
|
3
|
|
|
|
|
10
|
|
498
|
|
|
|
|
|
|
} else { |
499
|
0
|
|
|
|
|
0
|
$self->_do_error(108, $tk); |
500
|
|
|
|
|
|
|
} |
501
|
12
|
|
|
|
|
36
|
return $genid; |
502
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
} else { |
504
|
|
|
|
|
|
|
#print ">anonnode: ()\n"; |
505
|
20
|
|
|
|
|
48
|
my $next = $self->_eat_EOLs; |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
# if ($next =~ /^\)([,;\.\]\}\)])*$/) { |
508
|
20
|
100
|
|
|
|
59
|
if ($next =~ /^\)(.*)$/) { |
509
|
|
|
|
|
|
|
#print ">void ()\n"; |
510
|
3
|
|
|
|
|
16
|
$self->{reader}->get; |
511
|
3
|
50
|
|
|
|
12
|
unshift @{$self->{reader}->{tokens}}, $1 if $1; |
|
0
|
|
|
|
|
0
|
|
512
|
3
|
|
|
|
|
11
|
return $self->_built_in_verb('daml','nil'); |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
} else { |
515
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
#print ">anonnode () starts: $next\n"; |
517
|
17
|
|
|
|
|
28
|
my @nodes = (); |
518
|
17
|
|
|
|
|
40
|
until ($next =~ /^.*\)[,;\.\]\}\)]*$/) { |
519
|
31
|
|
|
|
|
66
|
push @nodes, $self->_object; |
520
|
31
|
|
|
|
|
76
|
$next = $self->_eat_EOLs; |
521
|
|
|
|
|
|
|
} |
522
|
17
|
50
|
|
|
|
76
|
if ($next =~ /^([^)]*)\)([,;\.\]\}\)]*)$/) { |
523
|
17
|
|
|
|
|
53
|
$self->{reader}->get; |
524
|
17
|
100
|
|
|
|
200
|
unshift @{$self->{reader}->{tokens}}, $2 if $2; |
|
10
|
|
|
|
|
32
|
|
525
|
17
|
|
|
|
|
22
|
unshift @{$self->{reader}->{tokens}}, ')'; |
|
17
|
|
|
|
|
40
|
|
526
|
17
|
50
|
|
|
|
45
|
if ($1) { |
527
|
0
|
|
|
|
|
0
|
unshift @{$self->{reader}->{tokens}}, $1; |
|
0
|
|
|
|
|
0
|
|
528
|
0
|
|
|
|
|
0
|
push @nodes, $self->_object; |
529
|
|
|
|
|
|
|
} |
530
|
17
|
|
|
|
|
46
|
$self->{reader}->get; |
531
|
|
|
|
|
|
|
} |
532
|
17
|
|
|
|
|
51
|
my $pref = $self->_built_in_verb('daml',''); |
533
|
|
|
|
|
|
|
|
534
|
17
|
|
|
|
|
23
|
my $i = 0; |
535
|
17
|
|
|
|
|
32
|
my @expnl = (); # expanded node list |
536
|
17
|
|
|
|
|
41
|
foreach (@nodes) { |
537
|
31
|
|
|
|
|
29
|
$i++; |
538
|
31
|
|
|
|
|
41
|
push @expnl, '['; |
539
|
31
|
|
|
|
|
45
|
push @expnl, $pref . 'first'; |
540
|
31
|
|
|
|
|
43
|
push @expnl, $_; |
541
|
31
|
|
|
|
|
38
|
push @expnl, ';'; |
542
|
31
|
|
|
|
|
40
|
push @expnl, $pref . 'rest'; |
543
|
31
|
100
|
|
|
|
105
|
push @expnl, $pref . 'nil' |
544
|
|
|
|
|
|
|
if $i == scalar @nodes; |
545
|
|
|
|
|
|
|
} |
546
|
17
|
|
|
|
|
46
|
for (my $j = 0; $j < $i; $j++) {push @expnl, ']'} |
|
31
|
|
|
|
|
71
|
|
547
|
17
|
|
|
|
|
18
|
unshift @{$self->{reader}->{tokens}}, @expnl; |
|
17
|
|
|
|
|
92
|
|
548
|
17
|
|
|
|
|
59
|
my $exp = join(' ', @expnl); |
549
|
|
|
|
|
|
|
#print ">expanded: $exp\n"; |
550
|
17
|
|
|
|
|
45
|
my $genid = $self->_anonymous_node; |
551
|
17
|
|
|
|
|
114
|
return $genid; |
552
|
|
|
|
|
|
|
} |
553
|
|
|
|
|
|
|
} |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
######################################## |
557
|
|
|
|
|
|
|
# utils |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
sub _exist_quantif { |
560
|
48
|
|
|
48
|
|
74
|
my ($self, $anode) = @_; |
561
|
|
|
|
|
|
|
|
562
|
48
|
100
|
|
|
|
123
|
if ($self->{quantif}) { |
563
|
13
|
|
|
|
|
34
|
my $qname = $self->_built_in_verb('log','forSome'); |
564
|
|
|
|
|
|
|
#print ">existential quantification: $anode\n"; |
565
|
|
|
|
|
|
|
#print ">CONTEXT: $self->{context}\n"; |
566
|
|
|
|
|
|
|
#print ">SUBJECT: $self->{context}\n"; |
567
|
|
|
|
|
|
|
#print ">PROPERTY: $qname"; |
568
|
|
|
|
|
|
|
#print ">-$anode\n"; |
569
|
13
|
|
|
|
|
73
|
$self->_process_statement($self->{context}, |
570
|
|
|
|
|
|
|
[[$qname, $anode]]); |
571
|
|
|
|
|
|
|
} |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
|
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
sub _eat_EOLs { |
576
|
1469
|
|
|
1469
|
|
1860
|
my ($self) = @_; |
577
|
|
|
|
|
|
|
|
578
|
1469
|
|
|
|
|
3676
|
my $next = $self->{reader}->try; |
579
|
1469
|
|
|
|
|
3556
|
while ($next eq ' EOL ') { |
580
|
172
|
|
|
|
|
433
|
$self->{reader}->get; |
581
|
172
|
|
|
|
|
2731
|
$next = $self->{reader}->try; |
582
|
|
|
|
|
|
|
} |
583
|
1469
|
|
|
|
|
3063
|
return $next; |
584
|
|
|
|
|
|
|
} |
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
# comment inside a list |
588
|
|
|
|
|
|
|
sub _check_inline_comment { |
589
|
286
|
|
|
286
|
|
383
|
my ($self, $next) = @_; |
590
|
|
|
|
|
|
|
|
591
|
286
|
50
|
|
|
|
588
|
if ($next =~ /^#/) { |
592
|
0
|
|
|
|
|
0
|
$self->_space; |
593
|
0
|
|
|
|
|
0
|
$next = $self->_eat_EOLs; |
594
|
|
|
|
|
|
|
} |
595
|
286
|
|
|
|
|
574
|
return $next; |
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
sub _built_in_verb { |
600
|
47
|
|
|
47
|
|
72
|
my ($self, $key, $verb) = @_; |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
# resolves possible NS conflicts |
603
|
47
|
|
|
|
|
57
|
my $i = 1; |
604
|
47
|
|
100
|
|
|
396
|
while ($self->{ns}->{$self->{context}}->{$self->{hardns}->{$key}->[0]} and |
605
|
|
|
|
|
|
|
$self->{ns}->{$self->{context}}->{$self->{hardns}->{$key}->[0]} ne |
606
|
|
|
|
|
|
|
$self->{hardns}->{$key}->[1]) { |
607
|
|
|
|
|
|
|
|
608
|
3
|
|
|
|
|
11
|
$self->{hardns}->{$key}->[0] = "$key$i"; |
609
|
3
|
|
|
|
|
11
|
$i++; |
610
|
|
|
|
|
|
|
} |
611
|
|
|
|
|
|
|
# adds prefix-NS binding |
612
|
47
|
|
|
|
|
163
|
$self->{ns}->{$self->{context}}->{$self->{hardns}->{$key}->[0]} = |
613
|
|
|
|
|
|
|
$self->{hardns}->{$key}->[1]; |
614
|
|
|
|
|
|
|
|
615
|
47
|
|
|
|
|
206
|
return "$self->{hardns}->{$key}->[0]:$verb"; |
616
|
|
|
|
|
|
|
} |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
sub _unesc_qname { |
620
|
5
|
|
|
5
|
|
7
|
my $qname = shift; |
621
|
|
|
|
|
|
|
|
622
|
|
|
|
|
|
|
#print ">escaped qname: $qname\n"; |
623
|
5
|
|
|
|
|
7
|
my $i = 0; |
624
|
5
|
|
|
|
|
8
|
my @unesc = (); |
625
|
5
|
|
|
|
|
17
|
while ($qname =~ /(__+)/) { |
626
|
0
|
|
|
|
|
0
|
my $res = substr(sprintf("%b", length($1) + 1), 1); |
627
|
0
|
|
|
|
|
0
|
$res =~ s/1/-/g; |
628
|
0
|
|
|
|
|
0
|
$res =~ s/0/_/g; |
629
|
0
|
|
|
|
|
0
|
$qname =~ s/__+/<$i>/; |
630
|
0
|
|
|
|
|
0
|
push @unesc, $res; |
631
|
0
|
|
|
|
|
0
|
$i++; |
632
|
|
|
|
|
|
|
} |
633
|
5
|
|
|
|
|
19
|
for ($i=0; $i<@unesc; $i++) { $qname =~ s/<$i>/$unesc[$i]/; } |
|
0
|
|
|
|
|
0
|
|
634
|
|
|
|
|
|
|
#print ">unescaped qname: $qname\n"; |
635
|
5
|
|
|
|
|
11
|
return $qname; |
636
|
|
|
|
|
|
|
} |
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
sub _unesc_string { |
640
|
23
|
|
|
23
|
|
47
|
my ($self, $str) = @_; |
641
|
|
|
|
|
|
|
|
642
|
23
|
|
|
|
|
43
|
$str =~ s/\\\n//go; |
643
|
23
|
|
|
|
|
39
|
$str =~ s/\\\\/\\/go; |
644
|
23
|
|
|
|
|
29
|
$str =~ s/\\'/'/go; |
645
|
23
|
|
|
|
|
33
|
$str =~ s/\\"/"/go; |
646
|
23
|
|
|
|
|
33
|
$str =~ s/\\n/\n/go; |
647
|
23
|
|
|
|
|
30
|
$str =~ s/\\r/\r/go; |
648
|
23
|
|
|
|
|
26
|
$str =~ s/\\t/\t/go; |
649
|
23
|
|
|
|
|
27
|
$str =~ s/\\u([\da-fA-F]{4})/pack('U',hex($1))/ge; |
|
0
|
|
|
|
|
0
|
|
650
|
23
|
|
|
|
|
33
|
$str =~ s/\\U00([\da-fA-F]{6})/pack('U',hex($1))/ge; |
|
0
|
|
|
|
|
0
|
|
651
|
23
|
|
|
|
|
27
|
$str =~ s/\\([\da-fA-F]{3})/pack('C',oct($1))/ge; #deprecated |
|
0
|
|
|
|
|
0
|
|
652
|
23
|
|
|
|
|
29
|
$str =~ s/\\x([\da-fA-F]{2})/pack('C',hex($1))/ge; #deprecated |
|
0
|
|
|
|
|
0
|
|
653
|
|
|
|
|
|
|
|
654
|
23
|
|
|
|
|
67
|
return $str; |
655
|
|
|
|
|
|
|
} |
656
|
|
|
|
|
|
|
|
657
|
|
|
|
|
|
|
######################################## |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
sub _do_error { |
660
|
0
|
|
|
0
|
|
|
my ($self, $n, $tk) = @_; |
661
|
|
|
|
|
|
|
|
662
|
0
|
|
|
|
|
|
my %msg = ( |
663
|
|
|
|
|
|
|
1 => 'file not specified', |
664
|
|
|
|
|
|
|
2 => 'file not found', |
665
|
|
|
|
|
|
|
3 => 'string not specified', |
666
|
|
|
|
|
|
|
4 => 'invalid parameter of quantification method (0|1)', |
667
|
|
|
|
|
|
|
|
668
|
|
|
|
|
|
|
101 => 'bind directive is obsolete, use @prefix instead', |
669
|
|
|
|
|
|
|
102 => 'invalid namespace prefix', |
670
|
|
|
|
|
|
|
103 => 'invalid URI reference (uri_ref2)', |
671
|
|
|
|
|
|
|
104 => 'end of verb (->) expected', |
672
|
|
|
|
|
|
|
105 => 'invalid characters in string1', |
673
|
|
|
|
|
|
|
106 => 'namespace prefix not bound', |
674
|
|
|
|
|
|
|
107 => 'invalid end of anonnode, ] expected', |
675
|
|
|
|
|
|
|
108 => 'invalid end of anonnode, } expected', |
676
|
|
|
|
|
|
|
109 => 'end of verb (of) expected', |
677
|
|
|
|
|
|
|
110 => 'end of verb (-<) expected', |
678
|
|
|
|
|
|
|
111 => 'string1 ("...") is not terminated', |
679
|
|
|
|
|
|
|
112 => 'invalid characters in string2', |
680
|
|
|
|
|
|
|
113 => 'string2 ("""...""")is not terminated', |
681
|
|
|
|
|
|
|
114 => 'string1 ("...") can\'t include newlines', |
682
|
|
|
|
|
|
|
115 => 'end of statement expected', |
683
|
|
|
|
|
|
|
116 => 'invalid node', |
684
|
|
|
|
|
|
|
117 => 'last keyword expected', |
685
|
|
|
|
|
|
|
199 => ':- token not supported yet', |
686
|
|
|
|
|
|
|
|
687
|
|
|
|
|
|
|
201 => '[Triples] attempt to add invalid node', |
688
|
|
|
|
|
|
|
202 => '[Triples] literal not allowed as subject or predicate', |
689
|
|
|
|
|
|
|
|
690
|
|
|
|
|
|
|
#301 => '[SAX] systemID source not implemented', |
691
|
|
|
|
|
|
|
302 => '[SAX] characterStream source not implemented', |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
401 => '[XML] unable to convert URI predicate to QName', |
694
|
|
|
|
|
|
|
402 => '[XML] subject not recognized - internal error', |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
501 => '[RDFCore] literal not allowed as subject', |
697
|
|
|
|
|
|
|
502 => '[RDFCore] valid storage not specified', |
698
|
|
|
|
|
|
|
503 => '[RDFStore] literal not allowed as subject', |
699
|
|
|
|
|
|
|
); |
700
|
|
|
|
|
|
|
|
701
|
0
|
|
|
|
|
|
my $msg = "[Error $n]"; |
702
|
0
|
0
|
|
|
|
|
$msg .= " line $self->{reader}->{ln}, token" if $n > 100; |
703
|
0
|
|
|
|
|
|
$msg .= " \"$tk\"\n"; |
704
|
0
|
|
|
|
|
|
$msg .= "$msg{$n}!\n"; |
705
|
0
|
|
|
|
|
|
croak $msg; |
706
|
|
|
|
|
|
|
} |
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
|
709
|
|
|
|
|
|
|
1; |
710
|
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
|
712
|
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
|
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
|