diff options
author | David Robillard <d@drobilla.net> | 2023-12-01 21:59:18 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | 9b1139fe7045a0630e87501235af21803860b80c (patch) | |
tree | 3a7cd3ee639e0b7a6f2244177819f8843202c692 /include/serd | |
parent | 94879f376f1d2b8fbb2322bf2a7dab5c3bb9e098 (diff) | |
download | serd-9b1139fe7045a0630e87501235af21803860b80c.tar.gz serd-9b1139fe7045a0630e87501235af21803860b80c.tar.bz2 serd-9b1139fe7045a0630e87501235af21803860b80c.zip |
[WIP] Add support for reading and writing variables
[WIP] Command line option, move later?
This adds a reader flag and serdi option for extending a syntax with support
for SPARQL-like variables, for storing things like patterns or simple queries.
Diffstat (limited to 'include/serd')
-rw-r--r-- | include/serd/node.h | 24 | ||||
-rw-r--r-- | include/serd/reader.h | 3 |
2 files changed, 23 insertions, 4 deletions
diff --git a/include/serd/node.h b/include/serd/node.h index b308a507..1faba160 100644 --- a/include/serd/node.h +++ b/include/serd/node.h @@ -38,9 +38,14 @@ typedef struct SerdNodeImpl SerdNode; /** Type of a node. - An abstract RDF node can be either a resource or a literal. This type is - more precise to preserve syntactic differences and support additional - features. + Note that this set of types is both more precise than, and extended from, + the possible types of an abstract RDF node. Not all types can occur in all + contexts, for example, a Turtle document can't contain a variable node. + + The string value of a node never contains quoting or other type indicators. + For example, the blank node `_:id3` and the plain literal `"id3"` from a + Turtle document would both have the same string, "id3", returned by + #serd_node_string. */ typedef enum { /** @@ -82,6 +87,19 @@ typedef enum { Turtle](http://www.w3.org/TR/turtle/#grammar-production-BLANK_NODE_LABEL) */ SERD_BLANK = 4, + + /** + A variable node. + + A variable's identity is, like blank nodes, local to its context. + Variables are typically used in interfaces for querying, rather than + present in data (there is no concept of a variable in RDF or its standard + syntaxes). + + @see [SPARQL 1.1 Query + Language](https://www.w3.org/TR/sparql11-query/#rVar) + */ + SERD_VARIABLE = 5, } SerdNodeType; /// Node flags, which ORed together make a #SerdNodeFlags diff --git a/include/serd/reader.h b/include/serd/reader.h index 4c669342..040f3398 100644 --- a/include/serd/reader.h +++ b/include/serd/reader.h @@ -29,7 +29,8 @@ typedef struct SerdReaderImpl SerdReader; /// Reader options typedef enum { - SERD_READ_LAX = 1U << 0U, ///< Tolerate invalid input where possible + SERD_READ_LAX = 1U << 0U, ///< Tolerate invalid input where possible + SERD_READ_VARIABLES = 1U << 1U, ///< Support variable nodes } SerdReaderFlag; /// Bitwise OR of SerdReaderFlag values |