REN is simple yet powerful data exchange format. It's very human friendly and pleasant to read. Every value in REN has it's own type to allow easier describtion of your data. See for yourself.
There are strings:
"hello world"
And there are words:
hello world ; hello world
Numbers are also supported in integer and floating point form.
1
-1
3.14
-2.354e3
Another type will tell you where to get help:
http://server.com/readme
You get the idea.
The basic form of data collection in REN is block.
[1 "a" [email protected] and so://on]
You can also add header to data transmission to inform the loader about type of data.
REN[
Title: "REN Example"
Type: example
Date: 5-4-2013
Expires: never
Version: 0.0.1
Author: "Boleslav Brezovsky"
]
"hello world"
{
hello multiline
world
}
word
3.14
[a b c d]
info: [time is 2:45 and date is 2013-4-5]
person: object! [
name: "Jaro"
age: 1
email: [email protected]
]
; this is comment
example: map! [
"key1" "value1"
"key2" http://value2.com
"key3" [email protected]
]
See? It's simple.
It's much easier to eyes than XML and JSON and at the same time it's at least as powerful. Broader datatype support is also great property of REN.
Whitespaces are space, tab and newline. They work as delimiters. There's no comma anywhere. You can put as many whitespaces as you want anywhere you want.
a:
[ 1
"b"
[email protected] ]
is same as
a: [1 "b" [email protected]]
Comments start with ;
; this is comment
There are two types of string. Single line and multi line. Single line string tarts and ends with quotes. Multiline string starts with {
and ends with }
. String is UTF-8 encoded. Special characters are escaped with ^
(see table below)
"single line"
{multi
line}
Character | Definition |
---|---|
^" | Inserts a double quote ("). |
^} | Inserts a closing brace (}). |
^^ | Inserts a caret (^). |
^/ | Starts a new line. |
^(line) | Starts a new line. |
^- | Inserts a tab. |
^(tab) | Inserts a tab. |
^(page) | Starts a new page. |
^(back) | Erases one character to the left of the insertion point. |
^(null) | Inserts a null character. |
^(escape) | Inserts an escape character. |
^(letter) | Inserts control-letter (A-Z). |
^(xxxx) | Inserts an Unicode character by hexidecimal (xxxx) number. |
Word contains alphanumerical characters, numbers and any of following characters:
? ! . ' + - * & | = _
Word cannot start with number. Words are used to construct domain specific languages (DSL) or dialects. More on DSL/dialects later.
word after word
Some syntax is reserved for future but not currently implemeted:
'world ; key reference with "'"
hello :world ; hello and get 'world key value
hello: world ; set hello to 'world
hello: :world ; set hello to 'world key value
Key (also set-word) is used to indicate that word should get following value. Format of set-word is word followed by colon.
a: 1
name: "Pepa"
color: #FF00FF
64bit integer number
1
-23242
Floating point number
3.14
1.2e34
Standard email - see RFC5322
Standard URI - see RFC3986
http://www.example.com
Date and time as defined in RFC3339 You can use slash instead of T, so it's more human readable.
12:45
14-3-2013
1-1-2000/13:20
1937-01-01T12:00:27.87+00:20
[ "this" is: block ]
Object is collection of set-words (keys) and values kept together in block and prefixed with object! word.
Map is similiar to object but can have strings as keys.
Header is optional but you are encouraged to use it. Unless you know what you are sending and where, you should add header as it enhances readability. Header can contain name, type, version, date, checksum and other useful informations about following data. Parse can for example just read header and decide if it makes sense to read rest of data (they may require higher version, data are expired etc.). Format of header is REN followed by block of key/value pairs. Header can be empty also.