design: Document option type

This commit is contained in:
Sasha Koshka 2025-10-15 18:15:07 -04:00
parent 77a4d7893f
commit 50ca98f3c6

View File

@ -33,6 +33,11 @@ PDL allows defining a protocol using HOPP and TAPE.
| {...} | KTV | * | Table with defined schema | {...} | KTV | * | Table with defined schema
| Any | * | * | Value of an undefined type | Any | * | * | Value of an undefined type
Tables with a defined schema can specify some fields as optional using a
question mark before the type. This will wrap the field the go-util
ucontainer.Option type. When encoding, void fields will not be included in the
output, and when decoding, unspecified fields are left void.
[^1]: Excluding SI and SBA. I5 and U5 cannot be used in an array, but String and [^1]: Excluding SI and SBA. I5 and U5 cannot be used in an array, but String and
Buffer are simply forced to use their "long" variant. Buffer are simply forced to use their "long" variant.
@ -48,6 +53,7 @@ structures. They are separated by whitespace.
| Method | `M[0-9A-Fa-f]{4}` | A 16-bit hexadecimal method code. | Method | `M[0-9A-Fa-f]{4}` | A 16-bit hexadecimal method code.
| Key | `[0-9A-Fa-f]{4}` | A 16-bit hexadecimal table key. | Key | `[0-9A-Fa-f]{4}` | A 16-bit hexadecimal table key.
| Ident | `[A-Z][A-Za-z0-9]` | An identifier. | Ident | `[A-Z][A-Za-z0-9]` | An identifier.
| Option | `?` | A question mark.
| Comma | `,` | A comma separator. | Comma | `,` | A comma separator.
| LBrace | `{` | A left curly brace. | LBrace | `{` | A left curly brace.
| RBrace | `}` | A right curly brace. | RBrace | `}` | A right curly brace.
@ -107,7 +113,7 @@ Below is an EBNF description of the language.
<method> -> /M[0-9A-Fa-f]{4}/ <method> -> /M[0-9A-Fa-f]{4}/
<key> -> /[0-9A-Fa-f]{4}/ <key> -> /[0-9A-Fa-f]{4}/
<ident> -> /[A-Z][A-Za-z0-9]/ <ident> -> /[A-Z][A-Za-z0-9]/
<field> -> <key> <ident> <type> <field> -> <key> <ident> ["?"] <type>
<type> -> <ident> <type> -> <ident>
| "[" "]" <type> | "[" "]" <type>
| "{" (<comment>* <field> ",")* [<comment>* <field>] "}" | "{" (<comment>* <field> ",")* [<comment>* <field>] "}"