INISON / inison

INISON -- Simple readable configuration and serialization format.
MIT License
0 stars 0 forks source link

Examples for another simple format #15

Open ghost opened 8 years ago

ghost commented 8 years ago

I think a super ini-style format capable of expressing any data structure easily is not what I really want. I like the flat looking of ini files. It is also easy to edit with any text editor, the best format for simple configurations.

Here is using a completely line-based format:

# Ths is a comment.
::map::  # specify the type of the top-level structure, optional
first run = true  # Spaces are allowed in the raw key. Crunched into a single space?

[User Profile]
first name = "Peter"
last name = "Pan"
birthday = "December 27, 1904" : Date
lucky numbers = [ 1, 3, 5, 7, 9 ]  # no nested arrays
# position = { x: 100, y: 200 }  # no object type, not kidding

[User Profile : Introduction] : text  # text mode
I am young.
I am vigorous.
I can fly in the sky.
I have magical power.
An apple a day keeps the doctor away.
::end::

[Dialogs] : list  # list mode, actually it may be a sub-parser for lines of text
"I have a dream, a big dream."
"Did I say that?"
"..."
::end::

[User Profile : Matrix] : list  # ok, your nested arrays
[ 1, 2, 3 ]
[ 4, 5, 6 ]
[ 7, 8, 9 ]
::end::

[[friends]]
name = "Obama"
motto = "I have a dream."
[[friends]]
name = "Salad"
motto = "Tasty!"

[[notes]] : text  # why not?
Today I have nothing to say.
::end::
[[notes]] : text
Nothing.
::end::
vagoff commented 8 years ago

birthday = "December 27, 1904" : Date

I thought about this, this is good idea; but that scares me off:

[a_section]
a_variable = "a very , very long string ....... ......... ...............  .............. " : sometype

beyond right edge of the screen

vagoff commented 8 years ago

A "super format capable of expressing any data structure easily" is known and that is TreeDef ;)

So let INISON be simpler.

ghost commented 8 years ago

A long base64 string of an image, or something else?

Remove tagging? :smiling_imp: Let the parser choose the best value type for specific keys, through some hooks.


There is an extreme TreeDef-like format with extreme YAML style: https://oli-lang.github.io/

vagoff commented 8 years ago

Remove tagging?

text mode ? DATE"" ?

extreme YAML style

Thanks, interesting. Yamlier than yaml...

ghost commented 8 years ago

If there is no custom parser for text blocks, text mode is just a special syntax for multiline strings, list mode is another syntax for arrays.

Date? Use a funtion to compare date strings; use parser postprocess hooks. Normally there are just a few dates in a file. Other types? Less used. Complex data types like RegExp? Use strings, only converted to regexps when needed. Tags everywhere? Choose a better DSL.

vagoff commented 8 years ago

Agreed.

As for tags and other my needs, TreeDef suits them completely.