REN is simple yet powerful data storage, exchange and notation format. It's very human friendly and pleasant to read. Every value in REN has its own type to allow easier description of your data. See for yourself.
There are strings:
"hello world"
And there are words:
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" e@ma.il and so://on]
You can also add header to data transmission to inform the loader about type of data.
REN[
name: Ren
occupation: "Data language"
purpose: {
Easily share data between people and machines.
Keep the rules simple.
Be useful.
}
version: 0.0.1
created: 5-Apr-2013
modified: 13:59:01
started: 5-Apr-2013/13:59+2:00
expires: never
]
home: https://github.com/humanistic/REN
email: info@ren-lang.org
complete?: no
comments-start-with: #";"
primary-delmiters: [#" " #"^-" #"^/"] ; space tab newline
test: (1 + 1)
starting-file: %readme.txt
off-the-beaten: 'a/b/c
axis: /x
bin-hex-val: #{48656C6C6F20776F726C6421}
bin-base-64-val: 64#{SGVsbG8gd29ybGQh}
number-of-supporters: 300
avg-IQ: 147.35
cost-to-use: $0.00
happy-users: 98.6%
common-hashtag: #ren
screen-size: 1920x1080
favorite-tag: <bold>
;favorite-color: 92.128.164
;lives-at: 127.0.0.1
object! [
a: 1
b: "test"
]
map! [
"key 1" 1
"key 2" "test"
]
dataypes: [
word! string! tuple! date! time! url! email! logic!
block! char! paren! file! path! refinement! binary!
integer! decimal! money! percent! issue! pair! tag!
object! map!
]
See? It's simple.
It's much easier on the 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"
c@d.e ]
is same as
a: [1 "b" c@d.e]
The question is, why comma?
-
Space doesn't visually bother as comma.
-
Space key is easier to hit than comma.
-
Having (white)space as delimiter allows simple creaton of DSLs or dialects.
See this example:
send someone@somewhere.com "Something"
In languages with poor datatype support this could be interpreted as:
{"send","someone@somewhere.com","Something" };
However languages with richer datatype support may understand this as for example Remote Procedure Call (RPC):
sendEmail("someone@somewhere.com","Something");
Just use it as you want to. It's simpler way to express itself.
Comments start with ;
; this is comment
There are two types of string. Single line and multi line. Single line string starts 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. |
NONE
is value that loader should convert to apropriate value in target language, for example NULL
.
NONE
There are six boolean values. Why not just two? Because TRUE
and FALSE
are not enough. Sometimes it's better to use YES
or NO
or ON
and OFF
.
TRUE
NO
ON
64bit integer number
1
-23242
Parser rules:
numbers: [#"0" - #"9"]
exponent: [#"e" | #"E"]
minus: #"-"
integer: [opt minus some numbers opt [exponent opt minus some numbers]]
Floating point number
3.14
1.2e34
Parser rules:
dot: #"."
float: [opt minus some numbers dot integer]
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
Parser rules:
letters: [#"a" - #"z" #"A" - #"Z"]
specials: [#"?" #"!" #"." #"'" #"+" #"-" #"*" #"&" #"|" #"=" #"_"]
characters: [some [letters | numbers | specials]]
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
Standard email - see RFC5322
test@example.com
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.
The header is optional but you are encouraged to use it. Unless you know what you are sending and where, you should include a header as it enhances readability. The header can contain name, type, version, date, checksum and other useful information about the data that follows. Parsers can then, for example, just read the header and decide if it makes sense to read the rest of the data. It may require version handling, deal with expired data etc. The header format is REN
followed by a block of key/value pairs. The header can also be empty.