From 6963fcf8be434c652c48d6450859fd947fb9a3a3 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Fri, 9 May 2025 22:17:19 +0300 Subject: [PATCH 1/2] Add UTF-8 and byte strings; closes https://github.com/OpenCyphal/specification/issues/51 --- specification/dsdl/grammar.parsimonious | 12 ++++++++---- specification/dsdl/grammar.tex | 4 +++- specification/dsdl/serializable_types.tex | 17 ++++++++++++----- specification/introduction/introduction.tex | 2 ++ 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/specification/dsdl/grammar.parsimonious b/specification/dsdl/grammar.parsimonious index d56cb251..27bdcd4c 100644 --- a/specification/dsdl/grammar.parsimonious +++ b/specification/dsdl/grammar.parsimonious @@ -47,18 +47,22 @@ type_scalar = type_versioned type_versioned = identifier ("." identifier)* "." type_version_specifier type_version_specifier = literal_integer_decimal "." literal_integer_decimal -type_primitive = type_primitive_truncated +type_primitive = type_primitive_boolean + / type_primitive_byte + / type_primitive_utf8 + / type_primitive_truncated / type_primitive_saturated +type_primitive_boolean = "bool" +type_primitive_byte = "byte" +type_primitive_utf8 = "utf8" type_primitive_truncated = "truncated" _ type_primitive_name type_primitive_saturated = ("saturated" _)? type_primitive_name # Defaults to this. -type_primitive_name = type_primitive_name_boolean - / type_primitive_name_unsigned_integer +type_primitive_name = type_primitive_name_unsigned_integer / type_primitive_name_signed_integer / type_primitive_name_floating_point -type_primitive_name_boolean = "bool" type_primitive_name_unsigned_integer = "uint" type_bit_length_suffix type_primitive_name_signed_integer = "int" type_bit_length_suffix type_primitive_name_floating_point = "float" type_bit_length_suffix diff --git a/specification/dsdl/grammar.tex b/specification/dsdl/grammar.tex index 86e14c36..ebf497cb 100644 --- a/specification/dsdl/grammar.tex +++ b/specification/dsdl/grammar.tex @@ -227,7 +227,9 @@ \subsection{Reserved identifiers}\label{sec:dsdl_reserved_identifiers} \texttt{saturated} & & Cast mode specifier \\ \texttt{true} & & Boolean literal \\ \texttt{false} & & Boolean literal \\ - \texttt{bool} & & Primitive type category \\ + \texttt{bool} & & Primitive type \\ + \texttt{utf8} & & Primitive type \\ + \texttt{byte} & & Primitive type \\ \texttt{u?int\textbackslash{}d*} & \texttt{uint8} & Primitive type category \\ \texttt{float\textbackslash{}d*} & \texttt{float} & Primitive type category \\ \texttt{u?q\textbackslash{}d+\_\textbackslash{}d+} & \texttt{q16\_8} & Primitive type category (future) \\ diff --git a/specification/dsdl/serializable_types.tex b/specification/dsdl/serializable_types.tex index e50f6f69..a759577d 100644 --- a/specification/dsdl/serializable_types.tex +++ b/specification/dsdl/serializable_types.tex @@ -80,6 +80,17 @@ \subsubsection{Hierarchy} The corresponding DSDL data type name pattern is ``\verb|uint[1-9]\d*|'', where the trailing integer represents the length of the serialized representation of the value, in bits, ranging from 1 to 64, inclusive. + \begin{itemize} + \item \textbf{UTF-8 octet.} This type is used as an element type of variable-length + arrays (section \ref{sec:dsdl_array_types}) containing UTF-8 encoded strings. + The DSDL name is ``\verb|utf8|''. + The only valid use of this type is as an element type of a variable-length array. + + \item \textbf{Byte.} This type is used as an element type of fixed-length or variable-length + arrays (section \ref{sec:dsdl_array_types}) containing an arbitrary sequence of bytes. + The DSDSL name is ``\verb|byte|''. + The only valid use of this type is as an element type of an array. + \end{itemize} \end{itemize} \item \textbf{Floating point types} are used to approximately represent real values. @@ -138,10 +149,6 @@ \subsubsection{Cast mode} Type category & Truncated mode & Saturated mode (default) \label{table:dsdl_cast_mode} \\ - Boolean & - Illegal: boolean type with truncated cast mode is not allowed. & - Falsity if the value is zero or false, truth otherwise. \\ - Signed integer & Illegal: signed integer types with truncated cast mode are not allowed. & Nearest reachable value. \\ @@ -189,7 +196,7 @@ \subsubsection{Reference list} \immediate\write18{../render_list_of_void_and_primitive_types.py > ../latex.tmp} \immediate\input{../latex.tmp} -\subsection{Array types} +\subsection{Array types}\label{sec:dsdl_array_types} An array type represents an ordered collection of values. All values in the collection share the same type, which is referred to as \emph{array element type}. diff --git a/specification/introduction/introduction.tex b/specification/introduction/introduction.tex index fbcc9b3a..e638cfd1 100644 --- a/specification/introduction/introduction.tex +++ b/specification/introduction/introduction.tex @@ -240,6 +240,8 @@ \subsection{v1.0 -- work in progress} \item The constraint on DSDL namespaces being defined in a single folder was removed. Namespaces can be hosted across multiple repositories and code can be generated from a union of said folders. + \item Support for UTF-8 strings and byte strings has been added. + \item Cyphal/UDP and Cyphal/serial transport specifications have been introduced. \end{itemize} From ab2856886ec54934daf52818e63f77d959f05a6a Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sat, 10 May 2025 03:12:05 +0300 Subject: [PATCH 2/2] Update specification/dsdl/serializable_types.tex Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- specification/dsdl/serializable_types.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specification/dsdl/serializable_types.tex b/specification/dsdl/serializable_types.tex index a759577d..1b93bd16 100644 --- a/specification/dsdl/serializable_types.tex +++ b/specification/dsdl/serializable_types.tex @@ -88,7 +88,7 @@ \subsubsection{Hierarchy} \item \textbf{Byte.} This type is used as an element type of fixed-length or variable-length arrays (section \ref{sec:dsdl_array_types}) containing an arbitrary sequence of bytes. - The DSDSL name is ``\verb|byte|''. + The DSDL name is ``\verb|byte|''. The only valid use of this type is as an element type of an array. \end{itemize} \end{itemize}