A namespace for manually parsing Turtle. Entry point is parse-doc.
A namespace for manually parsing Turtle. Entry point is parse-doc.
(add-range chars low high)
Adds a range of characters into set. chars - the set of characters. low - the low end of the character range to add, inclusive. high - the high end of the character range to add, inclusive. return - the set with the new range of characters added.
Adds a range of characters into set. chars - the set of characters. low - the low end of the character range to add, inclusive. high - the high end of the character range to add, inclusive. return - the set with the new range of characters added.
(anon-blank-node r c g triples)
Generates a new blank node with no properties. Already passed the opening [ character, and whitespace. This function just steps to the next position. r - The reader to parse from. c - The last character read. This must be a ] g - The generator. triples - An accumulating transient of triples. return: [r node gen triples more?] c - the character immediately after the node node - the new anonymous blank node gen - the updated generator triples - the updated triples sequence enf? - If this is a subject, then is this is not enough and properties are required. Always false.
Generates a new blank node with no properties. Already passed the opening [ character, and whitespace. This function just steps to the next position. r - The reader to parse from. c - The last character read. This must be a ] g - The generator. triples - An accumulating transient of triples. return: [r node gen triples more?] c - the character immediately after the node node - the new anonymous blank node gen - the updated generator triples - the updated triples sequence enf? - If this is a subject, then is this is not enough and properties are required. Always false.
(dot? c)
Maps ascii characters into their escape code
Maps ascii characters into their escape code
(escape r c)
Reads an escaped code from the input starting at the current position. r - the reader to parse from. c - the character after the \ character. return: [c value] c - the character after the escape sequence value - the unescaped character.
Reads an escaped code from the input starting at the current position. r - the reader to parse from. c - the character after the \ character. return: [c value] c - the character after the escape sequence value - the unescaped character.
(int-code x)
(maybe-parse-predicate r c gen triples)
Parses an IRI as a predicate if one is available. Otherwise return a nil as the IRI. r - The reader to parse from. c - the first character of the iri reference. gen - the current generator triples - the current triples return: [c iri gen triples] c - the last character read. iri - The iri string. gen - the generator. triples - the current triples.
Parses an IRI as a predicate if one is available. Otherwise return a nil as the IRI. r - The reader to parse from. c - the first character of the iri reference. gen - the current generator triples - the current triples return: [c iri gen triples] c - the last character read. iri - The iri string. gen - the generator. triples - the current triples.
(new-generator)
(newline? c)
(rdf-type generator)
Returns the rdf:type qname
Returns the rdf:type qname
(add-prefix generator prefix iri)
Adds a prefix/iri pair to the namespace map
Adds a prefix/iri pair to the namespace map
(new-iri generator iri)
Returns an IRI object.
Returns an IRI object.
(rdf-first generator)
Returns the rdf:first qname
Returns the rdf:first qname
(new-literal generator s)
(new-literal generator s t)
Returns a literal. Either simple, or with a type
Returns a literal. Either simple, or with a type
(new-qname generator prefix local)
Returns a Qualified Name object.
Returns a Qualified Name object.
(get-namespaces generator)
Returns a map of all the namespaces recorded by this generator
Returns a map of all the namespaces recorded by this generator
(rdf-rest generator)
Returns the rdf:rest qname
Returns the rdf:rest qname
(rdf-nil generator)
Returns the rdf:nil qname
Returns the rdf:nil qname
(iri-for generator prefix)
Gets the stored iri for a given prefix
Gets the stored iri for a given prefix
(new-lang-string generator s l)
Returns a string literal, with a language tag
Returns a string literal, with a language tag
(new-node generator)
(new-node generator label)
Generate a new node, optionally with a label indicating a reusable node. Return the next generator and node
Generate a new node, optionally with a label indicating a reusable node. Return the next generator and node
(get-base generator)
Returns the base of this generator, if one has been set
Returns the base of this generator, if one has been set
(add-base generator iri)
Adds a base iri for the document
Adds a base iri for the document
(parse in)
(parse in generator)
(parse in generator triples)
parse a string as a turtle document in - the string or Reader containing the document. g - an implementation of the Generator protocol for assigning blank nodes, IRIs and Literals, and managing namespaces. Optional. return: {:base <optional IRI> :namespaces <prefixes mapped to IRIs> :triples <vector of 3 element vectors>}
parse a string as a turtle document in - the string or Reader containing the document. g - an implementation of the Generator protocol for assigning blank nodes, IRIs and Literals, and managing namespaces. Optional. return: {:base <optional IRI> :namespaces <prefixes mapped to IRIs> :triples <vector of 3 element vectors>}
(parse-ambiguous-elt r c gen triples common-text non-iri-op)
Reads an object to the point where ambiguity can be resolved. Processes text as either a prefixed name or the text being searched on. r - The reader to parse from. c - The last character read gen - The current generator. triples - The current triples. common-text - The text that can start either type of line. non-iri-op - The function to use to parse the line if it does not contain triples. This function accepts the string and offset into the string return: [c gen triples] c - The last character read gen - the next generator state. obj - the object generated from parsing this object.
Reads an object to the point where ambiguity can be resolved. Processes text as either a prefixed name or the text being searched on. r - The reader to parse from. c - The last character read gen - The current generator. triples - The current triples. common-text - The text that can start either type of line. non-iri-op - The function to use to parse the line if it does not contain triples. This function accepts the string and offset into the string return: [c gen triples] c - The last character read gen - the next generator state. obj - the object generated from parsing this object.
(parse-ambiguous-line r c gen triples common-text non-triples-op)
Reads a line up to the point where ambiguity can be resolved. Processes the line as either the beginning of triples, or a provided operation. r - The reader to parse from. c - The last character read. (Optional: can be inferred) gen - The current generator. triples - The current triples. common-text - The text that can start either type of line. non-triples-op - The function to use to parse the line if it does not contain triples. This function accepts the incoming char. return: [c gen triples] c - The last character read. gen - the next generator state. triples - the triples generated from parsing this line.
Reads a line up to the point where ambiguity can be resolved. Processes the line as either the beginning of triples, or a provided operation. r - The reader to parse from. c - The last character read. (Optional: can be inferred) gen - The current generator. triples - The current triples. common-text - The text that can start either type of line. non-triples-op - The function to use to parse the line if it does not contain triples. This function accepts the incoming char. return: [c gen triples] c - The last character read. gen - the next generator state. triples - the triples generated from parsing this line.
(parse-base-end r gen end-char)
(parse-base-end r c gen end-char)
Parse an iri and the end-char for the end of the line. NOTE: THE FIRST ARITY OF THIS FUNCTION DOES NOT USE AN INCOMING CHARACTER r - The reader to parse from. c - [optional] The incoming character. gen - The generator to update. end-char - A test for the final character return: [c gen] c - character at position n gen - the new generator.
Parse an iri and the end-char for the end of the line. NOTE: THE FIRST ARITY OF THIS FUNCTION DOES NOT USE AN INCOMING CHARACTER r - The reader to parse from. c - [optional] The incoming character. gen - The generator to update. end-char - A test for the final character return: [c gen] c - character at position n gen - the new generator.
(parse-blank-node r c gen triples)
Parses a blank node label. r - The reader to parse from. n - The offset to parse from. c - the first character of the blank node gen - the current generator triples - the current triples return: [c node gen triples] n - The offset immediately after the prefix. c - the character at offset n. node - The blank node. gen - the generator. triples - the current triples.
Parses a blank node label. r - The reader to parse from. n - The offset to parse from. c - the first character of the blank node gen - the current generator triples - the current triples return: [c node gen triples] n - The offset immediately after the prefix. c - the character at offset n. node - The blank node. gen - the generator. triples - the current triples.
(parse-blank-node-entity r c gen triples)
Parse a blank node property/value list. Already past the opening [ character and whitespace. s - The reader to parse from c - The last character read gen - The generator for blank nodes and namespace resolution triples - An accumulating transient of triples. return [c node gen triples] c - The last character read node - the root blank node that is being parsed gen - the updated generator triples - the updated triples sequence enf? - is this enough if this is a subject? A predicateObject sequence is not needed. true.
Parse a blank node property/value list. Already past the opening [ character and whitespace. s - The reader to parse from c - The last character read gen - The generator for blank nodes and namespace resolution triples - An accumulating transient of triples. return [c node gen triples] c - The last character read node - the root blank node that is being parsed gen - the updated generator triples - the updated triples sequence enf? - is this enough if this is a subject? A predicateObject sequence is not needed. true.
(parse-collection r c gen triples)
Parses a collection. This creates a linked list in the triples. r - The parser to parse from. c - the first character of the collection gen - the current generator triples - the current triples return: [c node gen triples] c - the character immediately after the collection. node - The node representing the collection. gen - the generator. triples - the current triples.
Parses a collection. This creates a linked list in the triples. r - The parser to parse from. c - the first character of the collection gen - the current generator triples - the current triples return: [c node gen triples] c - the character immediately after the collection. node - The node representing the collection. gen - the generator. triples - the current triples.
(parse-iri r c gen triples)
Parse an iri. r - the reader to parse from. c - the char found at position n. gen - the generator to use. triples - the current triples. return: [c iri] c - the character after the iri. iri - the node for the parsed iri. Either an IRI string or an IRI. gen - the updated generator. triples - the triples generated in parsing the node.
Parse an iri. r - the reader to parse from. c - the char found at position n. gen - the generator to use. triples - the current triples. return: [c iri] c - the character after the iri. iri - the node for the parsed iri. Either an IRI string or an IRI. gen - the updated generator. triples - the triples generated in parsing the node.
(parse-iri-ref r c gen triples)
Parse an iri references. This is an iri string surrounded by <> characters. The <> characters are not returned. r - The reader to parse from. c - the first character of the iri reference. gen - the current generator triples - the current triples return: [c iri gen triples] c - the character at offset n. iri - The iri string. gen - the generator. triples - the current triples.
Parse an iri references. This is an iri string surrounded by <> characters. The <> characters are not returned. r - The reader to parse from. c - the first character of the iri reference. gen - the current generator triples - the current triples return: [c iri gen triples] c - the character at offset n. iri - The iri string. gen - the generator. triples - the current triples.
(parse-lang-tag r c gen triples lit-str)
Parse the language tag from a literal. The @ character has already been parsed. r - the reader to parse from. c - the last char read. gen - the node generator. triples - the current triples. lit-str - the literal string that this tag affects. return: [c literal gen triples] c - the character after the lang tag. literal - the parsed value, as a language literal. gen - the updated generator. triples - the triples generated in parsing the node.
Parse the language tag from a literal. The @ character has already been parsed. r - the reader to parse from. c - the last char read. gen - the node generator. triples - the current triples. lit-str - the literal string that this tag affects. return: [c literal gen triples] c - the character after the lang tag. literal - the parsed value, as a language literal. gen - the updated generator. triples - the triples generated in parsing the node.
(parse-literal r quote-c gen triples)
Parse a literal that starts with a quote character. This also includes the triple quote form that allows for raw unescaped strings. r - the reader to parse from. c - the last char read. This is a quote: either ' or " gen - the node generator. triples - the current triples. return: [c value gen triples] c - the first character after the literal. value - the parsed value, in string form if it is plain. gen - the updated generator. triples - the triples generated in parsing the node.
Parse a literal that starts with a quote character. This also includes the triple quote form that allows for raw unescaped strings. r - the reader to parse from. c - the last char read. This is a quote: either ' or " gen - the node generator. triples - the current triples. return: [c value gen triples] c - the first character after the literal. value - the parsed value, in string form if it is plain. gen - the updated generator. triples - the triples generated in parsing the node.
(parse-local r)
Parse a local into a string. r - The reader to parse from. return: [c local] c - the character after the local string. local - the parsed local name.
Parse a local into a string. r - The reader to parse from. return: [c local] c - the character after the local string. local - the parsed local name.
(parse-long-string r c end-q)
Parse a triple-quoted string form. Because this is already identified as a triple quote the offset of n and the character represent the first character after the quotes. r - the reader to parse from, after the quotes. c - the first char in the string. end-q - the ending quote character to terminate on, either ' or ". return: [c value] c - the character following the closing quotes. value - the parsed string.
Parse a triple-quoted string form. Because this is already identified as a triple quote the offset of n and the character represent the first character after the quotes. r - the reader to parse from, after the quotes. c - the first char in the string. end-q - the ending quote character to terminate on, either ' or ". return: [c value] c - the character following the closing quotes. value - the parsed string.
(parse-number r c gen triples)
Parse a numeric literal. r - the reader to parse from. c - the char found at position n. gen - the node generator. triples - the current triples. return: [c value] c - the character immediately after the number. value - the parsed number. gen - the updated generator triples - the triples generated in parsing the node.
Parse a numeric literal. r - the reader to parse from. c - the char found at position n. gen - the node generator. triples - the current triples. return: [c value] c - the character immediately after the number. value - the parsed number. gen - the updated generator triples - the triples generated in parsing the node.
(parse-object r c gen triples)
Parse an object entity, including any triples. r - the reader to parse from. c - the char found at position n. gen - the node generator. triples - the current triples. return: [c object gen triples] c - The last character read object - the node for the parsed object. gen - the updated generator. triples - the triples generated in parsing the node. Blank node entities can also return a true at the end of the vector, but this should be ignored.
Parse an object entity, including any triples. r - the reader to parse from. c - the char found at position n. gen - the node generator. triples - the current triples. return: [c object gen triples] c - The last character read object - the node for the parsed object. gen - the updated generator. triples - the triples generated in parsing the node. Blank node entities can also return a true at the end of the vector, but this should be ignored.
(parse-predicate-object-list r c subject gen triples)
Parse a predicate-object list r - The reader to parse from c - The character at position n gen - The generator for blank nodes and namespace resolution triples - An accumulating transient of triples. return [c gen triples] c - last character read gen - the updated generator triples - the updated triples sequence.
Parse a predicate-object list r - The reader to parse from c - The character at position n gen - The generator for blank nodes and namespace resolution triples - An accumulating transient of triples. return [c gen triples] c - last character read gen - the updated generator triples - the updated triples sequence.
(parse-prefix r c)
Parse a prefix. This is a simple string terminated with a ':'. The : character is not part of the prefix. s - The reader to parse from. c - The last character read. return: [c prefix] c - The character immediately after the prefix. prefix - The prefix string.
Parse a prefix. This is a simple string terminated with a ':'. The : character is not part of the prefix. s - The reader to parse from. c - The last character read. return: [c prefix] c - The character immediately after the prefix. prefix - The prefix string.
(parse-prefix-iri-end r gen end-char)
(parse-prefix-iri-end r c gen end-char)
Parse an iri and a newline for a PREFIX or BASE directive. NOTE: THE FIRST ARITY OF THIS FUNCTION DOES NOT USE AN INCOMING CHARACTER r - The reader to parse from. c - [optional] The incoming character. gen - The generator to update. end-char - A test for the final character return: [c gen] c - character at position n gen - the new generator.
Parse an iri and a newline for a PREFIX or BASE directive. NOTE: THE FIRST ARITY OF THIS FUNCTION DOES NOT USE AN INCOMING CHARACTER r - The reader to parse from. c - [optional] The incoming character. gen - The generator to update. end-char - A test for the final character return: [c gen] c - character at position n gen - the new generator.
(parse-prefixed-name r c gen triples)
(parse-prefixed-name r pre c gen triples)
Parse a prefix:local-name pair. r - The reader to parse from. pre - Optional. The initial part of the string that has already been parsed as a string builder. c - the first character of the prefixed name. gen - the generator triples - the current triples. return: [c prefix] c - The character immediately after the prefixed name. qname - The prefixed name as a IRI gen - the updated generator. triples - the triples generated in parsing the node.
Parse a prefix:local-name pair. r - The reader to parse from. pre - Optional. The initial part of the string that has already been parsed as a string builder. c - the first character of the prefixed name. gen - the generator triples - the current triples. return: [c prefix] c - The character immediately after the prefixed name. qname - The prefixed name as a IRI gen - the updated generator. triples - the triples generated in parsing the node.
(parse-statement r gen triples)
(parse-statement r c gen triples)
Parse a directive or triples. r - The reader to parse from. c - The last character read. (Optional: can be inferred) gen - The current generator. triples - The current triples. return: [c gen triples] c - The last character read. gen - the next generator state. triples - the triples generated from parsing this line.
Parse a directive or triples. r - The reader to parse from. c - The last character read. (Optional: can be inferred) gen - The current generator. triples - The current triples. return: [c gen triples] c - The last character read. gen - the next generator state. triples - the triples generated from parsing this line.
(parse-string r c end-q)
Parse a single-quoted string form. end-q - the ending quote character to terminate on. r - the reader to parse from. c - the last read char. This is after the opening quote character. return: [c value] c - the character immediately after the string. value - the parsed string.
Parse a single-quoted string form. end-q - the ending quote character to terminate on. r - the reader to parse from. c - the last read char. This is after the opening quote character. return: [c value] c - the character immediately after the string. value - the parsed string.
(parse-subject r c gen triples)
Parse a subject entity, including any triples. r - the reader to parse from. c - the char found at position n. gen - the node generator. triples - the current triples. return: [c subject gen triples] c - The last character read subject - the node for the parsed subject. gen - the updated generator triples - the triples generated in parsing the node. enf? - indicates if this subject is enough and a predicateObject list is not needed. Most types return nil for this (falsey).
Parse a subject entity, including any triples. r - the reader to parse from. c - the char found at position n. gen - the node generator. triples - the current triples. return: [c subject gen triples] c - The last character read subject - the node for the parsed subject. gen - the updated generator triples - the triples generated in parsing the node. enf? - indicates if this subject is enough and a predicateObject list is not needed. Most types return nil for this (falsey).
(parse-triples r c gen triples)
Parse a top level triples from a string. r - the reader to parse from. c - the character found at position n. gen - the generator to use for blank nodes. triples - A transient vector of triples. return: [c gen triples] c - The last character read gen - the next generator state. triples - the triples generated from parsing this line.
Parse a top level triples from a string. r - the reader to parse from. c - the character found at position n. gen - the generator to use for blank nodes. triples - A transient vector of triples. return: [c gen triples] c - The last character read gen - the next generator state. triples - the triples generated from parsing this line.
(parse-u-char r f)
Parse a an unescapped code of uxxxx or Uxxxxxxxx. A preceding \ character was just parsed. r - the reader to parse from. f - the character found at position n. Must be u or U. return: [c char] c - the char immediately after the u-char sequence char - the character code that was parsed, which may be a char, or a string with that char
Parse a an unescapped code of uxxxx or Uxxxxxxxx. A preceding \ character was just parsed. r - the reader to parse from. f - the character found at position n. Must be u or U. return: [c char] c - the char immediately after the u-char sequence char - the character code that was parsed, which may be a char, or a string with that char
(pre-parse-triples r c gen triples pre)
Parse a top level triples from a string, with some of the first triple already parsed as a prefixed stirng. r - the reader to parse from. c - the character found at position n. gen - the generator to use for blank nodes. triples - A transient vector of triples. pre - the previously read prefix of the line in a string builder return: [c gen triples] c - The last character read gen - the next generator state. triples - the triples generated from parsing this line.
Parse a top level triples from a string, with some of the first triple already parsed as a prefixed stirng. r - the reader to parse from. c - the character found at position n. gen - the generator to use for blank nodes. triples - A transient vector of triples. pre - the previously read prefix of the line in a string builder return: [c gen triples] c - The last character read gen - the next generator state. triples - the triples generated from parsing this line.
(relative-iri? s)
Indicates if an IRI is relative.
Indicates if an IRI is relative.
(reset-pos!)
(skip-past-dot r c)
Skip to the terminating dot. If non-whitespace is found, then report an error. r - The reader to parse from. return: c
Skip to the terminating dot. If non-whitespace is found, then report an error. r - The reader to parse from. return: c
(skip-to r c end-chars?)
Skip over the whitespace to the required character. If there are nonwhitespace characters, this is an error. r - The reader to parse from. c - The last character read. end-chars? - the set of chars to skip to. return: c c - the first character after the requested ending characters
Skip over the whitespace to the required character. If there are nonwhitespace characters, this is an error. r - The reader to parse from. c - The last character read. end-chars? - the set of chars to skip to. return: c c - the first character after the requested ending characters
(skip-whitespace r c)
Skip over the whitespace starting from a position in a string. r - The reader c - The character at the current position. return: c c - the first non-whitespace character
Skip over the whitespace starting from a position in a string. r - The reader c - The character at the current position. return: c c - the first non-whitespace character
(update-pos! r)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close