aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--include/serd/statement.h13
-rw-r--r--src/read_trig.c1
-rw-r--r--src/writer.c3
4 files changed, 11 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index a1ba8f6a..9dc3d414 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,7 @@ serd (1.1.1) unstable; urgency=medium
* Add support for xsd:float and xsd:double literals
* Bring read/write interface closer to C standard
* Make nodes opaque
+ * Preserve anonymous graph syntax in TriG
* Remove SERD_DISABLE_DEPRECATED and SERD_DEPRECATED_BY
* Remove serd_uri_to_path()
* Remove support for reading Turtle named inline nodes extension
diff --git a/include/serd/statement.h b/include/serd/statement.h
index 9d987922..a4109958 100644
--- a/include/serd/statement.h
+++ b/include/serd/statement.h
@@ -32,12 +32,13 @@ typedef enum {
typedef enum {
SERD_EMPTY_S = 1U << 0U, ///< Empty blank node subject
SERD_EMPTY_O = 1U << 1U, ///< Empty blank node object
- SERD_ANON_S = 1U << 2U, ///< Start of anonymous subject
- SERD_ANON_O = 1U << 3U, ///< Start of anonymous object
- SERD_LIST_S = 1U << 4U, ///< Start of list subject
- SERD_LIST_O = 1U << 5U, ///< Start of list object
- SERD_TERSE_S = 1U << 6U, ///< Start of terse subject
- SERD_TERSE_O = 1U << 7U, ///< Start of terse object
+ SERD_EMPTY_G = 1U << 2U, ///< Empty blank node graph
+ SERD_ANON_S = 1U << 3U, ///< Start of anonymous subject
+ SERD_ANON_O = 1U << 4U, ///< Start of anonymous object
+ SERD_LIST_S = 1U << 5U, ///< Start of list subject
+ SERD_LIST_O = 1U << 6U, ///< Start of list object
+ SERD_TERSE_S = 1U << 7U, ///< Start of terse subject
+ SERD_TERSE_O = 1U << 8U, ///< Start of terse object
} SerdStatementFlag;
/// Bitwise OR of SerdStatementFlag values
diff --git a/src/read_trig.c b/src/read_trig.c
index d710eaeb..e3d7a7e9 100644
--- a/src/read_trig.c
+++ b/src/read_trig.c
@@ -128,6 +128,7 @@ read_block(SerdReader* const reader, ReadContext* const ctx)
}
ctx->graph = token;
+ (*ctx->flags) |= (s_type == '[' ? SERD_EMPTY_G : 0U);
return read_wrappedGraph(reader, ctx);
}
diff --git a/src/writer.c b/src/writer.c
index 372e4279..940b22a0 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -923,7 +923,8 @@ write_blank(SerdWriter* const writer,
}
if ((field == SERD_SUBJECT && (flags & SERD_EMPTY_S)) ||
- (field == SERD_OBJECT && (flags & SERD_EMPTY_O))) {
+ (field == SERD_OBJECT && (flags & SERD_EMPTY_O)) ||
+ (field == SERD_GRAPH && (flags & SERD_EMPTY_G))) {
return esink("[]", 2, writer);
}
}