-
Notifications
You must be signed in to change notification settings - Fork 11
/
sdf-feature.cddl
239 lines (211 loc) · 6.77 KB
/
sdf-feature.cddl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
start = sdf-syntax
sdf-syntax = {
; info will be required in most process policies
? info: sdfinfo
? namespace: named<text>
? defaultNamespace: text
; Thing is a composition of objects that work together in some way
? sdfThing: named<thingqualities>
; Object is a set of Properties, Actions, and Events that together
; perform a particular function
? sdfObject: named<objectqualities>
; Includes Properties, Actions, and Events as well as sdfData
paedataqualities
* $$SDF-EXTENSION-TOP
EXTENSION-POINT<"top-ext">
}
sdfinfo = {
? title: text
? description: text
? version: text
? copyright: text
? license: text
? modified: modified-date-time
? features: [
* (any .feature "feature-name") ; EXTENSION-POINT
]
optional-comment
* $$SDF-EXTENSION-INFO
EXTENSION-POINT<"info-ext">
}
; Shortcut for a map that gives names to instances of X
; (has keys of type text and values of type X)
named<X> = { * text => X }
; EXTENSION-POINT is only used in framework syntax
EXTENSION-POINT<f> = ( * (quality-name .feature f) => any )
quality-name = text .regexp "([a-z][a-z0-9]*:)?[a-z$][A-Za-z$0-9]*"
sdf-pointer = global / same-object / true
global = text .regexp ".*[:#].*" ; rough CURIE or JSON Pointer syntax
same-object = referenceable-name
referenceable-name = text .regexp "[^:#]*"
; per se no point in having an empty list, but used for sdfRequired
; in odmobject-multiple_axis_joystick.sdf.json
pointer-list = [* sdf-pointer]
optional-comment = (
? $comment: text ; source code comments only, no semantics
)
commonqualities = (
? description: text ; long text (no constraints)
? label: text ; short text (no constraints); default to key
optional-comment
? sdfRef: sdf-pointer
; applies to qualities of properties, of data:
? sdfRequired: pointer-list
)
arraydefinitionqualities = (
? "minItems" => uint
? "maxItems" => uint
)
paedataqualities = (
; Property represents the state of an instance of an object
? sdfProperty: named<propertyqualities>
; Action invokes an application layer verb associated with an object
? sdfAction: named<actionqualities>
; Event represents an occurrence of event associated with an object
? sdfEvent: named<eventqualities>
; Data represents a piece of information that can be the state of a
; property or a parameter to an action or a signal in an event
? sdfData: named<dataqualities>
)
; for building hierarchy
thingqualities = {
commonqualities
? sdfObject: named<objectqualities>
? sdfThing: named<thingqualities>
paedataqualities
arraydefinitionqualities
* $$SDF-EXTENSION-THING
EXTENSION-POINT<"thing-ext">
}
; for single objects, or for arrays of objects
objectqualities = {
commonqualities
paedataqualities
arraydefinitionqualities
* $$SDF-EXTENSION-OBJECT
EXTENSION-POINT<"object-ext">
}
parameter-list = dataqualities
actionqualities = {
commonqualities
? sdfInputData: parameter-list ; sdfRequiredInputData applies here
? sdfOutputData: parameter-list ; sdfRequired applies here
; zero or more named data type definitions that might be used above
? sdfData: named<dataqualities>
* $$SDF-EXTENSION-ACTION
EXTENSION-POINT<"action-ext">
}
eventqualities = {
commonqualities
? sdfOutputData: parameter-list ; sdfRequired applies here
; zero or more named data type definitions that might be used above
? sdfData: named<dataqualities>
* $$SDF-EXTENSION-EVENT
EXTENSION-POINT<"event-ext">
}
sdftype-name = text .regexp "[a-z][-a-z0-9]*" ; EXTENSION-POINT
dataqualities = {
commonqualities
jsonschema
? "unit" => text
? nullable: bool
? "sdfType" => "byte-string" / "unix-time"
/ $SDF-EXTENSION-SDFTYPE .within sdftype-name
/ (sdftype-name .feature "sdftype-ext") ; EXTENSION-POINT
? contentFormat: text
* $$SDF-EXTENSION-DATA
EXTENSION-POINT<"data-ext">
}
propertyqualities = {
? observable: bool
? readable: bool
? writable: bool
~dataqualities
}
allowed-types = number / text / bool / null
/ [* number] / [* text] / [* bool]
/ {* text => any}
/ $SDF-EXTENSION-ALLOWED
/ (any .feature "allowed-ext") ; EXTENSION-POINT
compound-type = (
"type" => "object"
? required: [+text]
? properties: named<dataqualities>
)
optional-choice = (
? (("sdfChoice" => named<dataqualities>)
// ("enum" => [+ text])) ; limited to text strings
)
jsonschema = (
? (("type" => "number" / "string" / "boolean" / "integer" / "array")
// compound-type
// $$SDF-EXTENSION-TYPE
// (type: text .feature "type-ext") ; EXTENSION-POINT
)
; if present, all other qualities apply to all choices:
optional-choice
; the next three should validate against type:
? const: allowed-types
? default: allowed-types
; number/integer constraints
? minimum: number
? maximum: number
? exclusiveMinimum: number
? exclusiveMaximum: number
? multipleOf: number
; text string constraints
? minLength: uint
? maxLength: uint
? pattern: text ; regexp
? format: "date-time" / "date" / "time"
/ "uri" / "uri-reference" / "uuid"
/ $SDF-EXTENSION-FORMAT .within text
/ (text .feature "format-ext") ; EXTENSION-POINT
; array constraints
? minItems: uint
? maxItems: uint
? uniqueItems: bool
? items: jso-items
)
jso-items = {
? sdfRef: sdf-pointer ; import limited to subset allowed here...
? description: text ; long text (no constraints)
optional-comment
; leave commonqualities out for non-complex data types,
; but need the above three.
; no further nesting: no "array"
? ((type: "number" / "string" / "boolean" / "integer")
// compound-type
// $$SDF-EXTENSION-ITEMTYPE
// (type: text .feature "itemtype-ext") ; EXTENSION-POINT
)
; if present, all other qualities apply to all choices
optional-choice
; jso subset
? minimum: number
? maximum: number
? format: text
? minLength: uint
? maxLength: uint
* $$SDF-EXTENSION-ITEMS
EXTENSION-POINT<"items-ext">
}
modified-date-time = text .abnf modified-dt-abnf
modified-dt-abnf = "modified-dt" .det rfc3339z
; RFC 3339 sans time-numoffset, slightly condensed
rfc3339z = '
date-fullyear = 4DIGIT
date-month = 2DIGIT ; 01-12
date-mday = 2DIGIT ; 01-28, 01-29, 01-30, 01-31 based on
; month/year
time-hour = 2DIGIT ; 00-23
time-minute = 2DIGIT ; 00-59
time-second = 2DIGIT ; 00-58, 00-59, 00-60 based on leap sec
; rules
time-secfrac = "." 1*DIGIT
DIGIT = %x30-39 ; 0-9
partial-time = time-hour ":" time-minute ":" time-second
[time-secfrac]
full-date = date-fullyear "-" date-month "-" date-mday
modified-dt = full-date ["T" partial-time "Z"]
'