Skip to content

Commit 817449e

Browse files
Add UTF-8 and byte strings (#142)
Closes #51 See OpenCyphal/pydsdl#97 --------- Co-authored-by: Copilot <[email protected]>
1 parent 44521fb commit 817449e

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

specification/dsdl/grammar.parsimonious

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,22 @@ type_scalar = type_versioned
4747
type_versioned = identifier ("." identifier)* "." type_version_specifier
4848
type_version_specifier = literal_integer_decimal "." literal_integer_decimal
4949

50-
type_primitive = type_primitive_truncated
50+
type_primitive = type_primitive_boolean
51+
/ type_primitive_byte
52+
/ type_primitive_utf8
53+
/ type_primitive_truncated
5154
/ type_primitive_saturated
5255

56+
type_primitive_boolean = "bool"
57+
type_primitive_byte = "byte"
58+
type_primitive_utf8 = "utf8"
5359
type_primitive_truncated = "truncated" _ type_primitive_name
5460
type_primitive_saturated = ("saturated" _)? type_primitive_name # Defaults to this.
5561

56-
type_primitive_name = type_primitive_name_boolean
57-
/ type_primitive_name_unsigned_integer
62+
type_primitive_name = type_primitive_name_unsigned_integer
5863
/ type_primitive_name_signed_integer
5964
/ type_primitive_name_floating_point
6065

61-
type_primitive_name_boolean = "bool"
6266
type_primitive_name_unsigned_integer = "uint" type_bit_length_suffix
6367
type_primitive_name_signed_integer = "int" type_bit_length_suffix
6468
type_primitive_name_floating_point = "float" type_bit_length_suffix

specification/dsdl/grammar.tex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ \subsection{Reserved identifiers}\label{sec:dsdl_reserved_identifiers}
227227
\texttt{saturated} & & Cast mode specifier \\
228228
\texttt{true} & & Boolean literal \\
229229
\texttt{false} & & Boolean literal \\
230-
\texttt{bool} & & Primitive type category \\
230+
\texttt{bool} & & Primitive type \\
231+
\texttt{utf8} & & Primitive type \\
232+
\texttt{byte} & & Primitive type \\
231233
\texttt{u?int\textbackslash{}d*} & \texttt{uint8} & Primitive type category \\
232234
\texttt{float\textbackslash{}d*} & \texttt{float} & Primitive type category \\
233235
\texttt{u?q\textbackslash{}d+\_\textbackslash{}d+} & \texttt{q16\_8} & Primitive type category (future) \\

specification/dsdl/serializable_types.tex

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,17 @@ \subsubsection{Hierarchy}
8080
The corresponding DSDL data type name pattern is ``\verb|uint[1-9]\d*|'',
8181
where the trailing integer represents the length of the
8282
serialized representation of the value, in bits, ranging from 1 to 64, inclusive.
83+
\begin{itemize}
84+
\item \textbf{UTF-8 octet.} This type is used as an element type of variable-length
85+
arrays (section \ref{sec:dsdl_array_types}) containing UTF-8 encoded strings.
86+
The DSDL name is ``\verb|utf8|''.
87+
The only valid use of this type is as an element type of a variable-length array.
88+
89+
\item \textbf{Byte.} This type is used as an element type of fixed-length or variable-length
90+
arrays (section \ref{sec:dsdl_array_types}) containing an arbitrary sequence of bytes.
91+
The DSDL name is ``\verb|byte|''.
92+
The only valid use of this type is as an element type of an array.
93+
\end{itemize}
8394
\end{itemize}
8495

8596
\item \textbf{Floating point types} are used to approximately represent real values.
@@ -138,10 +149,6 @@ \subsubsection{Cast mode}
138149
Type category & Truncated mode & Saturated mode (default)
139150
\label{table:dsdl_cast_mode} \\
140151

141-
Boolean &
142-
Illegal: boolean type with truncated cast mode is not allowed. &
143-
Falsity if the value is zero or false, truth otherwise. \\
144-
145152
Signed integer &
146153
Illegal: signed integer types with truncated cast mode are not allowed. &
147154
Nearest reachable value. \\
@@ -189,7 +196,7 @@ \subsubsection{Reference list}
189196
\immediate\write18{../render_list_of_void_and_primitive_types.py > ../latex.tmp}
190197
\immediate\input{../latex.tmp}
191198

192-
\subsection{Array types}
199+
\subsection{Array types}\label{sec:dsdl_array_types}
193200

194201
An array type represents an ordered collection of values.
195202
All values in the collection share the same type, which is referred to as \emph{array element type}.

specification/introduction/introduction.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ \subsection{v1.0 -- work in progress}
240240
\item The constraint on DSDL namespaces being defined in a single folder was removed. Namespaces can be hosted
241241
across multiple repositories and code can be generated from a union of said folders.
242242

243+
\item Support for UTF-8 strings and byte strings has been added.
244+
243245
\item Cyphal/UDP and Cyphal/serial transport specifications have been introduced.
244246

245247
\item Minor adjustments of the transport layer definitions.

0 commit comments

Comments
 (0)