summaryrefslogtreecommitdiff
path: root/doc/formats.html
blob: 8dea5eedd89439736be812affff962721e7dfcec (plain)
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="generator" content="Docutils 0.5: http://docutils.sourceforge.net/" />
<title>Formats and Languages</title>
<style type="text/css">

/*
:Author: David Goodger (goodger@python.org)
:Id: $Id: html4css1.css 5196 2007-06-03 20:25:28Z wiemann $
:Copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.

See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
customize this style sheet.
*/

/* used to remove borders from tables and images */
.borderless, table.borderless td, table.borderless th {
  border: 0 }

table.borderless td, table.borderless th {
  /* Override padding for "table.docutils td" with "! important".
     The right padding separates the table cells. */
  padding: 0 0.5em 0 0 ! important }

.first {
  /* Override more specific margin styles with "! important". */
  margin-top: 0 ! important }

.last, .with-subtitle {
  margin-bottom: 0 ! important }

.hidden {
  display: none }

a.toc-backref {
  text-decoration: none ;
  color: black }

blockquote.epigraph {
  margin: 2em 5em ; }

dl.docutils dd {
  margin-bottom: 0.5em }

/* Uncomment (and remove this text!) to get bold-faced definition list terms
dl.docutils dt {
  font-weight: bold }
*/

div.abstract {
  margin: 2em 5em }

div.abstract p.topic-title {
  font-weight: bold ;
  text-align: center }

div.admonition, div.attention, div.caution, div.danger, div.error,
div.hint, div.important, div.note, div.tip, div.warning {
  margin: 2em ;
  border: medium outset ;
  padding: 1em }

div.admonition p.admonition-title, div.hint p.admonition-title,
div.important p.admonition-title, div.note p.admonition-title,
div.tip p.admonition-title {
  font-weight: bold ;
  font-family: sans-serif }

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
  color: red ;
  font-weight: bold ;
  font-family: sans-serif }

/* Uncomment (and remove this text!) to get reduced vertical space in
   compound paragraphs.
div.compound .compound-first, div.compound .compound-middle {
  margin-bottom: 0.5em }

div.compound .compound-last, div.compound .compound-middle {
  margin-top: 0.5em }
*/

div.dedication {
  margin: 2em 5em ;
  text-align: center ;
  font-style: italic }

div.dedication p.topic-title {
  font-weight: bold ;
  font-style: normal }

div.figure {
  margin-left: 2em ;
  margin-right: 2em }

div.footer, div.header {
  clear: both;
  font-size: smaller }

div.line-block {
  display: block ;
  margin-top: 1em ;
  margin-bottom: 1em }

div.line-block div.line-block {
  margin-top: 0 ;
  margin-bottom: 0 ;
  margin-left: 1.5em }

div.sidebar {
  margin: 0 0 0.5em 1em ;
  border: medium outset ;
  padding: 1em ;
  background-color: #ffffee ;
  width: 40% ;
  float: right ;
  clear: right }

div.sidebar p.rubric {
  font-family: sans-serif ;
  font-size: medium }

div.system-messages {
  margin: 5em }

div.system-messages h1 {
  color: red }

div.system-message {
  border: medium outset ;
  padding: 1em }

div.system-message p.system-message-title {
  color: red ;
  font-weight: bold }

div.topic {
  margin: 2em }

h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
  margin-top: 0.4em }

h1.title {
  text-align: center }

h2.subtitle {
  text-align: center }

hr.docutils {
  width: 75% }

img.align-left {
  clear: left }

img.align-right {
  clear: right }

ol.simple, ul.simple {
  margin-bottom: 1em }

ol.arabic {
  list-style: decimal }

ol.loweralpha {
  list-style: lower-alpha }

ol.upperalpha {
  list-style: upper-alpha }

ol.lowerroman {
  list-style: lower-roman }

ol.upperroman {
  list-style: upper-roman }

p.attribution {
  text-align: right ;
  margin-left: 50% }

p.caption {
  font-style: italic }

p.credits {
  font-style: italic ;
  font-size: smaller }

p.label {
  white-space: nowrap }

p.rubric {
  font-weight: bold ;
  font-size: larger ;
  color: maroon ;
  text-align: center }

p.sidebar-title {
  font-family: sans-serif ;
  font-weight: bold ;
  font-size: larger }

p.sidebar-subtitle {
  font-family: sans-serif ;
  font-weight: bold }

p.topic-title {
  font-weight: bold }

pre.address {
  margin-bottom: 0 ;
  margin-top: 0 ;
  font-family: serif ;
  font-size: 100% }

pre.literal-block, pre.doctest-block {
  margin-left: 2em ;
  margin-right: 2em }

span.classifier {
  font-family: sans-serif ;
  font-style: oblique }

span.classifier-delimiter {
  font-family: sans-serif ;
  font-weight: bold }

span.interpreted {
  font-family: sans-serif }

span.option {
  white-space: nowrap }

span.pre {
  white-space: pre }

span.problematic {
  color: red }

span.section-subtitle {
  /* font-size relative to parent (h1..h6 element) */
  font-size: 80% }

table.citation {
  border-left: solid 1px gray;
  margin-left: 1px }

table.docinfo {
  margin: 2em 4em }

table.docutils {
  margin-top: 0.5em ;
  margin-bottom: 0.5em }

table.footnote {
  border-left: solid 1px black;
  margin-left: 1px }

table.docutils td, table.docutils th,
table.docinfo td, table.docinfo th {
  padding-left: 0.5em ;
  padding-right: 0.5em ;
  vertical-align: top }

table.docutils th.field-name, table.docinfo th.docinfo-name {
  font-weight: bold ;
  text-align: left ;
  white-space: nowrap ;
  padding-left: 0 }

h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
  font-size: 100% }

ul.auto-toc {
  list-style-type: none }

</style>
</head>
<body>
<div class="document" id="formats-and-languages">
<h1 class="title">Formats and Languages</h1>

<p>The formats and languages used by Tangible Bit are explained in English and
(in some cases) formally defined in EBNF.</p>
<div class="section" id="ebnf-grammar">
<h2>EBNF Grammar</h2>
<p>We use the EBNF notation as used in the <a class="reference external" href="http://golang.org/doc/go_spec.html#Notation">Go Language Specification</a>, which is almost identical
to a subset of standard ISO EBNF.</p>
<p>Additionally, we use the “except” construct from ISO EBNF:</p>
<dl class="docutils">
<dt>A - B</dt>
<dd>Matches any string that matches A but does not match B.</dd>
</dl>
<p>We use <tt class="docutils literal"><span class="pre">#xN</span></tt>, where N is a hexadecimal integer, to match the character
whose Unicode code point is N.</p>
</div>
<div class="section" id="predefined-rules">
<h2>Predefined Rules</h2>
<p>The following EBNF rules are assumed to be predefined and not formally
defined in this document:</p>
<dl class="docutils">
<dt>Char</dt>
<dd>Any Unicode character.</dd>
<dt>UnicodeLetter</dt>
<dd>A character classified as “Letter” in the Unicode database.</dd>
<dt>UnicodeDigit</dt>
<dd>A character classified as “Digit” in the Unicode database.</dd>
</dl>
</div>
<div class="section" id="polyps">
<h2>Polyps</h2>
<p>Here’s the EBNF of the <em>Polyps</em> language:</p>
<pre class="literal-block">

Polyp = { Statement &quot;;&quot; } .

Statement = Declaration | Call .

Declaration = VariableDeclaration | FunctionDeclaration .

VariableDeclaration = [ &quot;var&quot; ] VariableList  &quot;:=&quot; ExpressionList .
FunctionDeclaration = [ &quot;def&quot; ] Function &quot;:=&quot; Expression .

VariableList = variable { &quot;,&quot; variable } .
ExpressionList = Expression { &quot;,&quot; Expression } .

// ForLoop = &quot;for&quot; Condition Block .

// Block = &quot;{&quot; Polyp &quot;}&quot; .

Function = identifier Parameters .
Parameters = &quot;(&quot; [ ParameterList ] &quot;)&quot; .
ParameterList = variable { &quot;,&quot; variable } .

Call = identifier &quot;(&quot; [ ExpressionList ] &quot;)&quot; .
BuiltinCall = identifier &quot;(&quot; [ ExpressionList ] &quot;)&quot; .

Expression = Expr { log_op Expr } .

Expr = UnaryExpr | Expr binary_op UnaryExpr .

UnaryExpr = [ &quot;(&quot; ] PrimaryExpr [ &quot;)&quot; ] | unary_op [ &quot;(&quot; ] PrimaryExpr [ &quot;)&quot; ] .

PrimaryExpr = BuiltinCall | Call | Expr | Operand .

Operand = Literal | identifier .
Literal = int_lit | float_lit .

binary_op = rel_op | math_op .
log_op = &quot;|&quot; | &quot;&amp;&quot; .
rel_op = &quot;=&quot; | &quot;!=&quot; | &quot;&lt;&quot; | &quot;&gt;&quot; | &quot;&lt;=&quot; | &quot;&gt;=&quot; | &quot;&lt;&gt;&quot; .
math_op = &quot;+&quot; | &quot;-&quot; | &quot;*&quot; | &quot;/&quot; | &quot;%&quot; | &quot;^&quot; | &quot;**&quot; .
unary_op = &quot;+&quot; | &quot;-&quot; | &quot;!&quot; | &quot;¬&quot; | &quot;~&quot; .

// Boolean = true | false .
// true = &quot;True&quot; .
// false = &quot;False&quot; .
// none = &quot;None&quot; .

variable = identifier .

identifier = letter { letter | unicode_digit } .

unicode_letter = &quot;a&quot; ... &quot;z&quot; | &quot;A&quot; ... &quot;Z&quot; .
unicode_digit = decimal_digit .
letter        = unicode_letter | &quot;_&quot; .
decimal_digit = &quot;0&quot; ... &quot;9&quot; .
octal_digit   = &quot;0&quot; ... &quot;7&quot; .
hex_digit     = &quot;0&quot; ... &quot;9&quot; | &quot;A&quot; ... &quot;F&quot; | &quot;a&quot; ... &quot;f&quot; .

int_lit     = decimal_lit | octal_lit | hex_lit .
decimal_lit = ( &quot;1&quot; ... &quot;9&quot; ) { decimal_digit }  | &quot;0&quot; .
octal_lit   = &quot;0&quot; octal_digit { octal_digit } .
hex_lit     = &quot;0&quot; ( &quot;x&quot; | &quot;X&quot; ) hex_digit { hex_digit } .

float_lit = decimals &quot;.&quot; [ decimals ] [ exponent ] |
            decimals exponent |
            &quot;.&quot; decimals [ exponent ] |
            [ &quot;+&quot; | &quot;-&quot; ] &quot;nan&quot; | [ &quot;+&quot; | &quot;-&quot; ] &quot;inf&quot; .
decimals  = decimal_digit { decimal_digit } .
exponent  = ( &quot;e&quot; | &quot;E&quot; ) [ &quot;+&quot; | &quot;-&quot; ] decimals .

// char_lit         = &quot;'&quot; ( unicode_value | byte_value ) &quot;'&quot; .
// unicode_value    = unicode_char | little_u_value | big_u_value | escaped_char .
// byte_value       = octal_byte_value | hex_byte_value .
// octal_byte_value = `\` octal_digit octal_digit octal_digit .
// hex_byte_value   = `\` &quot;x&quot; hex_digit hex_digit .
// little_u_value   = `\` &quot;u&quot; hex_digit hex_digit hex_digit hex_digit .
// big_u_value      = `\` &quot;U&quot; hex_digit hex_digit hex_digit hex_digit
//                           hex_digit hex_digit hex_digit hex_digit .
// escaped_char     = `\` ( &quot;a&quot; | &quot;b&quot; | &quot;f&quot; | &quot;n&quot; | &quot;r&quot; | &quot;t&quot; | &quot;v&quot; | `\` | &quot;'&quot; | `&quot;` ) .

// StringLit              = string_lit { string_lit } .
// string_lit             = raw_string_lit | interpreted_string_lit .
// raw_string_lit         = &quot;`&quot; { unicode_char } &quot;`&quot; .
// interpreted_string_lit = `&quot;` { unicode_value | byte_value } `&quot;` .


</pre>
<p>TODO unicode_letter and unicode_digit should really be Unicode letters (as
defined above), not just ASCII letters.</p>
</div>
<div class="section" id="tangible-data-format-tdf">
<h2>Tangible Data Format (TDF)</h2>
<p>TDF is used as general-purpose data serialization format for object
definitions and representations (and possibly other purposes). The data
model is roughly equivalent to JSON, but TDF is meant to be easily readable
and writable by humans, as well as being easily parsable and serializable
by computers. TDF is a superset of the popular <a class="reference external" href="http://www.faqs.org/rfcs/rfc5322.html">RFC 5322</a> “name: value”
format, adding support for lists and nested content as well as for
Windows-INI-style “[section]” blocks (as syntactic sugar).</p>
<ul class="simple">
<li>There are two types of <em>values</em>: <em>compounds</em> and <em>atoms</em>.</li>
<li>There are two types of <em>compounds</em>: <em>lists</em> and <em>maps</em>.</li>
<li>There are two types of <em>lists</em>: <em>block lists</em> and <em>inline lists</em>.</li>
<li><em>Block lists</em> contain one or more <em>block list items</em>. (Note: the <em>empty
list</em>—a <em>list</em> with zero items—must be written as an <em>inline list</em>,
since <em>block lists</em> must contain at least one item.)</li>
<li><em>Block list items</em> are either <em>simple items</em> or <em>complex items</em>. If a
<em>block list item</em> spans multiple lines, all subsequent lines must be
<em>deeper indented</em> than the first one. All <em>block list items</em> in a <em>block
list</em> must start at the same <em>indentation level</em> (they must be preceded
by the same amount of <em>inline whitespace</em>).</li>
<li><em>Simple items</em> are introduced by a hyphen (-), followed by <em>whitespace</em>
and an <em>atom</em>.</li>
<li><em>Complex items</em> are introduced by a plus sign (+), followed by
<em>whitespace</em> and a <em>compound</em>.</li>
<li><em>Inline lists</em> are enclosed in curly brackets (“{…}”) and contain zero
or more <em>inline list items</em>.</li>
<li><em>Inline list items</em> are <em>atoms</em> or <em>inline lists</em> (<em>inline lists</em> can
contain nested <em>inline lists</em>, but they cannot contain <em>block lists</em> or
<em>maps</em>).</li>
<li>Successive <em>inline list items</em> are separated by a comma (,).</li>
<li><em>Maps</em> contain zero or more <em>pairs</em>. All <em>pairs</em> in a <em>map</em> must start at
the same <em>indentation level</em> (they must be preceded by the same amount of
<em>inline whitespace</em>).</li>
<li><em>Pairs</em> are either <em>simple pairs</em> or <em>complex pairs</em>. If a <em>pair</em> spans
multiple lines, all subsequent lines must be <em>deeper indented</em> than the
first one.</li>
<li><em>Simple pairs</em> contain a <em>key</em> followed by an <em>atom</em>, separated by a
colon (:) followed by <em>whitespace</em>.</li>
<li><em>Complex pairs</em> contain a <em>key</em> followed by a <em>compound</em>, separated by
two colons (::) followed by <em>whitespace</em>.</li>
<li><em>Keys</em> are <em>atoms</em>. The <em>keys</em> of all <em>pairs</em> in the <em>maps</em> must be
distinct—no <em>map</em> may contain the same <em>key</em> several times. <em>Integer</em>
and <em>float</em> representations of the same numeric value are considered as
identical (a <em>map</em> cannot contain the <em>keys</em> “3” and “3.0” at the same
time).</li>
<li>There are three types of <em>atoms</em>: <em>strings</em>, <em>numbers</em> and <em>literals</em>.</li>
<li>There are three <em>literals</em> (all written without the surrounding quotes):
“true”, “false” (representing the two Boolean values), and “null”
(representing the null/nil/nothing value).</li>
<li>There are two types of <em>numbers</em>: <em>integers</em> and <em>floats</em>. <em>Integers</em> are
written like decimal integers in Polyps (cf. the <tt class="docutils literal"><span class="pre">decimal_lit</span></tt> rule
above—octal and hexadecimal notations are not supported); <em>floats</em> are
written as in Polyps (cf. the <tt class="docutils literal"><span class="pre">float_lit</span></tt> rule above).</li>
<li><em>Strings</em> are sequences of zero or more Unicode characters. If a
<em>strings</em> looks like an <em>atom</em> of another kinds (a <em>number</em> or <em>literal</em>)
or if it starts with an opening bracket ([) or curly bracket ({) or with
<em>whitespace</em>, its first character must be <em>backslash-escaped</em>. If a
<em>string</em> ends with <em>whitespace</em>, its last character must be
<em>backslash-escaped</em>—if a string ends in a single backslash, followed by
a <em>linebreak</em> or the end of the document, that counts as a
<em>backslash-escaped</em> <em>linebreak</em> at the end of the string (it’s not
necessary to explicitly add an extra <em>linebreak</em>). Plus or minus signs
(+-) at the start of a string must be <em>backslash-escaped</em> if followed by
<em>whitespace</em> (to prevent confusion with <em>lists</em>). The hash sign (#) must
be escaped at the start of the string or if preceded by <em>whitespace</em> (to
prevent confusion with <em>comments</em>). Colons (:) must be
<em>backslash-escaped</em> within <em>keys</em>; commas (,) and curly brackets ({})
must be <em>backslash-escaped</em> within <em>inline list items</em>. Backslashes (\)
must be <em>backslash-escaped</em> within all <em>strings</em>. <em>Backslash-escaping</em>
other characters is allowed, but not required.</li>
<li>Characters are <em>backslash-escaped</em> by writing a backslash (\) in front
of the character.</li>
<li><em>Complex maps</em> are <em>maps</em> that contain only <em>complex pairs</em> (i.e. <em>keys</em>
followed by <em>compounds</em>). There is an alternative syntax for serializing
all the <em>complex pairs</em> of a <em>complex map</em>, provided that none of the
<em>compounds</em> in the <em>complex pairs</em> is the <em>empty list</em> (a <em>list</em> with
zero items): the <em>key</em> can be written as a <em>bracket key</em> on a line of its
own, enclosed in brackets (“[…]”) and followed by the <em>compound</em> in
subsequent lines. In this case, the <em>compound</em> must start at the same
<em>indentation level</em> as the preceding <em>bracket key</em> (it must NOT be
<em>deeper indented</em>). The <em>compounds</em> themselves must NOT use this
alternative syntax for <em>complex maps</em>, even if they are <em>complex maps</em>
(since it would be impossible to distinguish <em>bracket keys</em> belonging to
the inner from those belonging to the outer <em>complex map</em>). <em>Compounds</em>
that are <em>lists</em> must be serialized as <em>block lists</em>, not as <em>inline
lists</em> (otherwise they could be easily confused with <em>bracket
keys</em>—that’s the reason that <em>lists</em> with zero items are forbidden in
this alternative syntax: <em>block lists</em> must always have at least one
item). (This alternative syntax is similar to the syntax of Windows “INI”
files and Python’s “configparser” module.)</li>
<li><em>Whitespace</em> is any combination of <em>inline whitespace</em>, <em>linebreaks</em>, and
the vertical tab (#x0B) and form feed (#x0C) characters.</li>
<li><em>Inline whitespace</em> is any combination of space (#x20) and tab (#x09)
characters.</li>
<li>There are three <em>linebreaks</em>: just LF (#x0A, Unix style), just CR (#x0D,
old Mac style), and CR followed by LF (Windows style).</li>
<li>Indentation expresses nesting. The sequence of <em>inline whitespace</em>
between the start of a line and a <em>value</em> determines the <em>indentation
level</em> of the <em>value</em>. Other <em>values</em> start at the same <em>indentation
level</em> if they are separated by the same sequence of <em>inline whitespace</em>
from the start of the line; they are <em>deeper intended</em> if they are
separated from the start of the line by the same sequence of <em>inline
whitespace</em>, followed by additional <em>inline whitespace</em>. (Note that it’s
not possible to exchange spaces for tabs or vice versa. If one <em>value</em> is
preceded by, say, 8 spaces, and another one by 1 tab, they won’t start at
the same <em>indentation level</em>, since the sequences of <em>inline whitespace</em>
preceding them differ; neither is one of them <em>deeper indented</em> than the
other, since neither whitespace sequence is a prefix of the other one.)</li>
<li><em>Comments</em> are introduced by a hash sign (#) and extend until the end of
the line. <em>Comments</em> can occur anywhere, but they must always be preceded
by <em>whitespace</em> (except for a <em>comment</em> that occurs at the very start of
the file). All <em>comments</em> and all <em>whitespace</em> preceding them on the same
line are discarded when reading TDF documents.</li>
<li>A TDF <em>document</em> is a <em>compound</em>.</li>
</ul>
<p>For examples, see the <tt class="docutils literal"><span class="pre">.tt</span></tt> files in the <tt class="docutils literal"><span class="pre">data/types</span></tt> directory and the
<tt class="docutils literal"><span class="pre">.tb</span></tt> files in the <tt class="docutils literal"><span class="pre">sample</span></tt> directory.</p>
</div>
<div class="section" id="tangible-bit-query-language-tql">
<h2>Tangible Bit Query Language (TQL)</h2>
<p>Used to query for objects, locations and other items contained in the TBit
database. Here’s the EBNF:</p>
<pre class="literal-block">
query		=	tablename '?' statement .

statement 	= 	'(' + statement + ')' 
		| 	booleanstatement 
		|	logicalstatement .

booleanstatement = 	statement '&amp;' statement 
		| 	statement '|' statement 
		| 	'!' statement .

logicalstatement =	logicalstatement ('&lt;'|'&gt;'|'&lt;='|'=&gt;'|'=='|'!='|'~')
                        logicalstatement .
		|	value .
		|	variable .

value		=	floatnumber | decimalnumber | hexnumber |
                        octalnumber | string .

variable	=	 identifier .

tablename	=	 identifier .

identifier = UnicodeLetter { UnicodeLetter | UnicodeDigit } .

floatnumber = decimals &quot;.&quot; [ decimals ] [ exponent ] |
              decimals exponent |
              &quot;.&quot; decimals [ exponent ] |
              [ &quot;+&quot; | &quot;-&quot; ] &quot;nan&quot; | [ &quot;+&quot; | &quot;-&quot; ] &quot;inf&quot; .
decimals  = decimal_digit { decimal_digit } .
exponent  = ( &quot;e&quot; | &quot;E&quot; ) [ &quot;+&quot; | &quot;-&quot; ] decimals .

decimalnumber = ( &quot;1&quot; ... &quot;9&quot; ) { decimal_digit }  | &quot;0&quot; .
hexnumber     = 0&quot; ( &quot;x&quot; | &quot;X&quot; ) hex_digit { hex_digit }.
octalnumber   = &quot;0&quot; octal_digit { octal_digit } .
decimal_digit = &quot;0&quot; ... &quot;9&quot; .
hex_digit     = &quot;0&quot; ... &quot;9&quot; | &quot;A&quot; ... &quot;F&quot; | &quot;a&quot; ... &quot;f&quot; .
octal_digit   = &quot;0&quot; ... &quot;7&quot; .

string = '&quot;' { normalchar | escapedchar } '&quot;'.
normalchar  = Char - '&quot;' - &quot;\&quot; .
escapedchar = &quot;\&quot; Char .

# Char, UnicodeLetter and UnicodeDigit are assumed to be predefined.
# Example: materials ? (30 &lt;= shearmodulus &lt;= 50)

</pre>
<ul class="simple">
<li>TODO Calculations: evaluate to an atom using standard operators arithmetic
operators (+, -, *, /, %).  Can contain Atoms. Grouping is used where
necessary to resolve ambiguities.</li>
<li>Conditions: evaluate to a Boolean using standard Boolean syntax: logical
connectives (! &amp; | ^), relational operators (== != &lt; &gt; &lt;= &gt;=), set
operators (in ~). Can contain calculations and atoms and atom lists.
Grouping is used where necessary to resolve ambiguities.</li>
</ul>
</div>
<div class="section" id="tangible-bit-declaration-language-tdl">
<h2>Tangible Bit Declaration Language (TDL)</h2>
<p>Used to the declare the properties of objects and processes. TODO describe</p>
</div>
<div class="section" id="tangible-bit-type-definitions-ttd">
<h2>Tangible Bit Type Definitions (TTD)</h2>
<p>TODO describe interpretation of TTD; object and complex type declarations:
uri and desc fields, 4 keywords blocks: req, opt, reqlist, optlist (all
optional, order doesn’t matter); describe variant used for <tt class="docutils literal"><span class="pre">basetypes.tt</span></tt>
(basic types). Possibly define additional <em>optlist</em> field for child
categories: <tt class="docutils literal"><span class="pre">parent</span></tt> contains the URI of the parent category/categories
(but in the base types, we just specify the parent type in parentheses
after the name)—probably unify name and URI and allow declaring a
<tt class="docutils literal"><span class="pre">&#64;prefix</span></tt> field for relative URIs (cf. prefixes used in N3/RDF). Each
file should contain the declaration of an object category as well as any
complex types used in its definition.</p>
</div>
</div>
</body>
</html>