2 Types are written with ''type definitions'' <tt>''type <name> = <type>''</tt>.
3 The builtin types are denoted by their names (<tt>Boolean</tt>, <tt>Byte</tt>, <tt>Integer</tt>, <tt>Long</tt>, <tt>Float</tt>, <tt>Double</tt>, <tt>String</tt>, <tt>Variant</tt>)
7 Complex type definitions and in particular recursive ones can be defined in pieces by giving names to types:
8 type NodeDescription = referable { name : String, children : NodeDescription[] }
10 All other type constructors have form <tt>C(T<sub>1</sub>, ..., T<sub>k</sub>)</tt>, where <tt>C</tt> is a type constructor
11 and parameters are datatypes. The following constructors are defined:
12 type Example = Optional( BaseType )
14 Parametrised type constructors can be defined as follows:
15 type Tree(A) = | Leaf A | Node referable { left : Tree(A), right : Tree(A) }
17 type Sample(Value) = { time : Double, value : Value }
20 Built-in types can be annotated. Annotations are written as <tt>T(key<sub>1</sub>=value<sub>1</sub>, ..., key<sub>k</sub>=value<sub>k</sub>)</tt>,
21 where <tt>key<sub>i</sub></tt> is an identifier and <tt>value<sub>i</sub></tt> a value of some built-in type (depending on the annotation).
23 type value = Integer(range=[1..10000])
24 type Probability = Double(range=[0..1.0])
25 type XML = String(mimeType="text/xml")
26 type Html = String(pattern="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?", length=[..4096])
29 The following annotations are defined:
34 ** pattern : String (regular expression pattern of allowed strings, case sensitive)
38 type Size = Integer(range=[1..10000], unit="m")
39 type Amplitude = Double(range=[-1.0..1.0])
40 type Frequency = Double(unit="1/s")
41 type Document = String(mimeType="text/xml")
44 A record type is constructed as <tt>{ f<sub>1</sub> : T<sub>1</sub>, ..., f<sub>k</sub> : T<sub>k</sub> }</tt>,
45 where <tt>f<sub>i</sub></tt> is a field name and <tt>T<sub>i</sub></tt> its datatype. A field name cannot be empty and two field names cannot
47 Field names are usually written in lowercase.
48 type Color = { red : Double,
52 ===Referable Record===
53 Referable record is a record prefixed with keyword <tt>referable</tt>.
54 type Tree = referable { children : Tree[] }
57 A tuple type is a special case of record type where all components have empty names. The construction is in the following format (''T''<sub>1</sub>, ..., ''T''<sub>k</sub>).
58 type Vector = (Integer, Integer, Integer)
61 A union type is constructed as <tt>| n<sub>1</sub> T<sub>1</sub> | ... | n<sub>k</sub> T<sub>k</sub></tt>, where <tt>n<sub>i</sub></tt> is a tag name and <tt>T<sub>i</sub></tt> its datatype.
62 The tag type is optional and is assumed to be <tt>{}</tt>, if left out. Tag names have to be non-empty and distinct.
63 Tag names are usually capitalized.
64 type Color = | RGB (Float, Float, Float)
65 | RGBA (Float, Float, Float, Float)
67 Enumerations are also unions. The type names are left out. Name of the type is used as the tag name.
68 type Method = | Disabled | Adaptive | Manual
70 type CommandResponse = | Success
73 A tag may have the same name as a builtin datatype
74 type Example = | Double Double | Long Long
77 The textual notation for the array type construction is <tt>T[]</tt>, where <tt>T</tt> is the base type.
78 type VGA = Double[320][240]
81 Minimum and maximum length of the array can be specified as <tt>T[a..]</tt>, <tt>T[..b]</tt>, <tt>T[a..b]</tt> or <tt>T[a]</tt>,
82 where <tt>a</tt> and <tt>b</tt> are integers and <tt>a</tt> ≤ <tt>b</tt>.
83 *Exact Value <tt>Double[ 0 ]</tt>
84 *Unlimited <tt>Double[]</tt>
85 *Limited <tt>Double[ ..100 ]</tt>, <tt>Double[ 10..100 ]</tt>, <tt>Double[ 10.. ]</tt>
88 Map type is defined as <tt>Map(K, V)</tt>, where <tt>K</tt> is key datatype, and <tt>V</tt> is value datatype.
90 type TimeSeries = Map( Long(unit="ms"), Double );
91 type PropertyMap = Map( String, String )
94 If is defined as <tt>''type : value''</tt>.
96 {x=50, y=50, z=50} : { x:Double, y:Double, z:Double }
97 (50, 50, 50) : { x:Double, y:Double, z:Double }
100 An optional type is constructed with a base type. Its values are the values of
101 the base type and a special value ''null''.
103 type Name = Optional( String )
104 exmpl1 : Name = "Hei"
108 Value if (''.dbv'') is a text file that contains a single data value in text format.
109 The type must be known to the reader.
111 Value definition file is a text file (''.dbd'') that contains a list of value definitions.
112 There is a name, type, and value in a ''Value definition'' in the following format: <tt>''<name> : <type> = <value>''</tt>.
114 It is assumed that the datatype of the value written in textual format is always known
115 in the context. Thus it is not necessary to be able to completely infer the type from
116 the value notation itself.
119 obj2 : { name : String } = { name = "ABC" }
120 obj3 : Node = { id = "123", parent = obj4 }
122 ''Strings'' are written by enclosing the string in double quotes. The special characters
123 in the strings are escaped following Java-specification. [http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101089]
125 "string with special characters such as:\n - \\\n - \"\n"
127 ''Long strings'' containing special characters and new lines are enclosed in triple double quotes:
131 Characters cannot be escaped in this notation (?).
133 ''Integers'' are specified with a sequence of digits preceded by an optional '-'. ''Floating point numbers'' can contain also dot and exponent. The exact syntax follows the Java specification for ''int'' and ''double'' literals.
140 The fields of a record value are enclosed in curly brackets {} and separated by comma. Each field consists of the field name, equality mark and the value.
141 pink : Color = { red = 1.0, green = 0.4, blue = 0.4 }
143 Long field names are escaped with single quotes. The special characters
144 in the strings are escaped following Java-specification. [http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101089]
145 type Example = { 'long field name' : Double }
146 value : Example = { 'long field name' = 5.0 }
148 ===Referable Record===
149 value in the following format: ''<name> : <type> = <value>''.
150 Referable values are referred by name.
151 root : Tree = { children = [ node1, node2 ] }
152 node1 : Tree = { children = [] }
153 node2 : Tree = { children = [] }
156 vec1 : Vector = (1, 2, 3)
158 When exactly one value is enclosed in parenthesis, the parenthesis are interpreted as grouping not as a tuple. Thus the following two lines are equal:
163 The value consists of the union tag name followed by a value:
164 result : CommandResponse = Error "The method call failed."
165 white : Color = RGBA (1,1,1,0)
167 Long union tags are escaped with single quotes. The special characters
168 in the strings are escaped following Java-specification. [http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101089]
169 type Example2 = | 'long union name' (1,1,1)
172 The values are enclosed in brackets [] and separated by comma.
173 image : Names = ["a", "b", "c"]
176 Map value is a collection of entries. They are enclosed in curly brackets {} and separated by comma (,). Each entry consists of the key name, equals (=) mark and the value.
177 properties : PropertyMap = map { Name = "Somename", Id = "6.0" }
179 Long field names are escaped with single quotes. The special characters
180 in the strings are escaped following Java-specification. [http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#101089]
181 properties : PropertyMap = map { "string key name" = "5.0", "another key name" = "6.0" }
184 Type can be omited for strings and booleans
185 "Hello World" : String
190 Type can also be omited for numbers with the following rule. If there is a full stop (.) then the type is a Double, otherwise an Integer.
197 Record fields of optional type can be omited, if there is no value.
199 name : Optional (String)
202 exmp2 : Example = { name = "abc" }
206 {| border="1" cellpadding="3" cellspacing="0" align="center"
210 |<tt>.dbt</tt> ||Databoard Type Definition File. Consists of type definitions in text format.
212 |<tt>.dbd</tt> ||Databoard Value Definition file. Consists of value definitions in text format.
214 |<tt>.dbv</tt> ||Databoard Value File. Contains a single value in text format without type information.