aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-12-02 15:53:25 -0500
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:08 -0500
commit339f9d90d1fe001978d15e1c007a3861a7145453 (patch)
treed29ec45610ad04a79dd353fbb2609bbb2931148f /include
parent4711fdf527f416faee8ff19e15f050d4b48dcfb2 (diff)
downloadserd-339f9d90d1fe001978d15e1c007a3861a7145453.tar.gz
serd-339f9d90d1fe001978d15e1c007a3861a7145453.tar.bz2
serd-339f9d90d1fe001978d15e1c007a3861a7145453.zip
[WIP] Add support for converting literals to canonical form
Diffstat (limited to 'include')
-rw-r--r--include/serd/canon.h47
-rw-r--r--include/serd/serd.h1
2 files changed, 48 insertions, 0 deletions
diff --git a/include/serd/canon.h b/include/serd/canon.h
new file mode 100644
index 00000000..862a4db0
--- /dev/null
+++ b/include/serd/canon.h
@@ -0,0 +1,47 @@
+// Copyright 2011-2022 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#ifndef SERD_CANON_H
+#define SERD_CANON_H
+
+#include "serd/attributes.h"
+#include "serd/sink.h"
+#include "serd/world.h"
+#include "zix/attributes.h"
+
+#include <stdint.h>
+
+SERD_BEGIN_DECLS
+
+/**
+ @defgroup serd_canon Canon
+ @ingroup serd_streaming
+ @{
+*/
+
+/// Flags that control canonical node transformation
+typedef enum {
+ SERD_CANON_LAX = 1U << 0U, ///< Tolerate and pass through invalid input
+} SerdCanonFlag;
+
+/// Bitwise OR of SerdCanonFlag values
+typedef uint32_t SerdCanonFlags;
+
+/**
+ Return a new sink that transforms literals to canonical form where possible.
+
+ The returned sink acts like `target` in all respects, except literal nodes
+ in statements may be modified from the original.
+*/
+SERD_API SerdSink* ZIX_ALLOCATED
+serd_canon_new(const SerdWorld* ZIX_NONNULL world,
+ const SerdSink* ZIX_NONNULL target,
+ SerdCanonFlags flags);
+
+/**
+ @}
+*/
+
+SERD_END_DECLS
+
+#endif // SERD_CANON_H
diff --git a/include/serd/serd.h b/include/serd/serd.h
index 88be5daa..d264192f 100644
--- a/include/serd/serd.h
+++ b/include/serd/serd.h
@@ -69,6 +69,7 @@
@{
*/
+#include "serd/canon.h"
#include "serd/env.h"
#include "serd/event.h"
#include "serd/sink.h"