modules/rdf/parser/common.zzm

rdf-0.0.3 documentation

NAME

rdf/parser/common - Shared RDF parser helpers.

SYNOPSIS

  from rdf/parser/common import RDFReader;

  let reader := new RDFReader(source: "<http://example.com/s>");
  let term := reader.read_iri();

DESCRIPTION

This module contains the shared reader used by the N-Triples, N-Quads, Turtle, and RDF/XML parsers. It is primarily useful for parser implementors. Public parser classes should normally be preferred by application code.

EXPORTS

Classes

  • RDFReader

    A cursor over a source string with namespace, base IRI, blank node, term, literal, and N-Triples/N-Quads statement readers.

    • advance(Number count)

      Moves the cursor and returns the reader.

    • position()

      Returns the current cursor offset.

    • fresh_blank()

      Returns a generated blank node term.

    • set_base(String value)

      Sets the base IRI used by resolve_iri and returns the reader.

    • read_iri()

      Reads an IRI reference and resolves it against the reader base.

    • read_absolute_iri()

      Reads an IRI and throws unless it is absolute.

    • resolve_iri(String iri)

      Returns iri resolved against the reader base.

    • read_name()

      Reads an ASCII name token used by the shared parsers.

    • read_blank_label()

      Reads a blank node label after _:.

    • read_prefixed_name()

      Reads a Turtle/SPARQL prefixed name using the reader prefix map.

    • read_prefixed_or_keyword()

      Reads a prefixed name or the a keyword as rdf:type.

    • read_blank()

      Reads a blank node term.

    • read_string_literal(Boolean long_allowed, Boolean single_allowed, String escape_mode)

      Reads a string literal. The flags control triple-quoted and single-quoted forms. escape_mode selects the grammar-specific escape rules.

    • read_langtag()

      Reads a language tag.

    • read_literal()

      Reads a Turtle literal.

    • read_nt_literal()

      Reads an N-Triples/N-Quads literal.

    • read_number_token()

      Reads a numeric token and returns its lexical form and datatype.

    • read_number_or_boolean()

      Reads a Turtle numeric or boolean literal.

    • read_term(), read_subject(), read_object()

      Read Turtle-style terms in the named positions.

    • read_nt_subject(), read_nt_predicate(), read_nt_object(), read_nt_graph()

      Read N-Triples/N-Quads terms in the named positions.

    • read_nt_statement(Boolean graph_allowed)

      Reads one N-Triples or N-Quads statement.

    • read_nt_all(Boolean graph_allowed)

      Reads all N-Triples or N-Quads statements from the source.

    • read_statement(Boolean graph_allowed), read_all(Boolean graph_allowed)

      Compatibility aliases for statement and source readers.

COPYRIGHT AND LICENCE

rdf/parser/common 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.