Cobra Data Language
Posted: Wed Jul 08, 2009 12:12 am
I often need to load in configuration data or potentially exchange data between two Cobra programs. There is of course XML, JSON, YAML, etc. but it would be nice to have something Cobra-centric as another option. Here is a quick, incomplete example:
As in Cobra, dictionaries and lists are not whitespace sensitive so you could write:
And here is a very lightweight spec. I'm looking for feedback and questions.
{
'id': 500,
'created': <2009-07-08 00:07>,
'isActive': true,
'location': Point(5, 10),
'numbers': [2, 4, 6, 8]
}
As in Cobra, dictionaries and lists are not whitespace sensitive so you could write:
{"up": 1, "down": -1}
And here is a very lightweight spec. I'm looking for feedback and questions.
primitives:
ints
decimals/floats
strings "foo" 'bar'
nil
booleans: true, false
extended primitives:
dates <2009-07-07>
times <23:00> <23:00:00>
datetimes <2009-07-07[T]23:00:00>
timespan <???>
colors <#ef7d99> <#eee> <rgb 128 128 128> <rgb .5 .5 .5> <hsb .9 .8 .7>
objects:
ClassName()
ClassName(value, value)
ClassName(property=value, property=value)
ClassName(value, value, property=value)
lists:
[1, 2, 3]
sets:
{1, 2, 3}
{,}
maps/dictionaries:
{key: value, key: value}
{:}