=encoding utf8
=head1 NAME
rdf/parser - shared RDF parser trait.
=head1 SYNOPSIS
from rdf/parser import RdfParser;
=head1 DESCRIPTION
C<RdfParser> provides the common parser entry points used by the RDF
parser classes. Classes compose the trait and implement C<parse_string>.
=head1 EXPORTS
=head2 Traits
=over
=item C<RdfParser>
=over
=item C<< parse_string(String text, ... options) >>
Placeholder parser method. Classes using this trait should override it.
=item C<< parse_file(path, ... options) >>
Reads UTF-8 from C<path> and parses it.
=item C<< parse_lines(Array lines, ... options) >>
Parses concatenated line chunks.
=item C<< parse_chunks(Array chunks, ... options) >>
Parses concatenated string or nested-array chunks.
=back
=back
=head1 COPYRIGHT AND LICENCE
B<< rdf/parser >> is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under
the terms of either the Artistic License 1.0 or the GNU General Public
License version 2.
=cut
function _rdf_parser_concat_chunks ( Array chunks ) {
let text := "";
for ( let chunk in chunks ) {
if ( chunk instanceof Array ) {
text _= _rdf_parser_concat_chunks(chunk);
}
else {
text _= chunk;
}
}
return text;
}
trait RdfParser {
method parse_string ( String text, ... PairList options ) {
die "Unimplemented";
}
method parse_file ( path, ... PairList options ) {
return self.parse_string(path.slurp_utf8(), ...options);
}
method parse_lines ( Array lines, ... PairList options ) {
return self.parse_string(_rdf_parser_concat_chunks(lines), ...options);
}
method parse_chunks ( Array chunks, ... PairList options ) {
return self.parse_string(_rdf_parser_concat_chunks(chunks), ...options);
}
}
modules/rdf/parser.zzm
rdf-0.0.3 source code
Package
- Name
- rdf
- Version
- 0.0.3
- Uploaded
- 2026-06-12 23:55:02
- Repository
- https://github.com/tobyink/zuzu-rdf
- Dependencies
-
-
std/data/xml>= 0 -
std/data/xml/escape>= 0 -
std/data/json>= 0 -
std/db>= 0 -
std/digest/sha>= 0 -
std/getopt>= 0 -
std/internals>= 0 -
std/io>= 0 -
std/math>= 0 -
std/proc>= 0 -
std/string>= 0 -
std/time>= 0 -
std/uuid>= 0
-
- Metadata
- zuzu-distribution.json
- Archive
- Download .tar.gz