dsrbecky / Conf

Data-centric alternative to XML which is suitable for configuration files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Conf - simple data-centric alternative to XML suitable for configuration files

=== Introduction ===

Take the following XML file for example:

<Button Text="Hello world!">
	<Location>
		<Point X="20" Y="10"/>
	</Location>
</Button>

Get rid of all attributes - they can expressed as elements:

<Button>
	<Text>"Hello world!"</Text>
	<Location>
		<Point>
			<X>20</X>
			<Y>10</Y>
		</Point>
	</Location>
</Button>

Modify the element syntax to use curly brackets:

Button {
	Text { "Hello world!" }
	Location {
		Point {
			X { 20 }
			Y { 10 }
		}
	}
}

Introduce "Name = Value" as syntactic sugar for "Name { Value }": 

Button {
	Text = "Hello world!"
	Location = Point { X = 20 Y = 10 }
}

Done

=== Goals of the language ===

"Simple data-centric alternative to XML suitable for configuration files"

	Simple - The language should be as simple as possible.  It should be quick
		to learn and simple to write parser for.
	
	Data-centric - The XML format is document-centric.  The original use was to
		insert markup elements into a text document.  XHTML is a great example
		of this.  Although it does the job quite well, XML was not designed for
		the purpose of data storage.  This language focuses on data-storage
		rather than document markup.
		
	Alternative to XML - The language should be viable alternative to XML in
	    vast majority of data-centric applications.
	
	Suitable for configuration files - Configuration files are dully noted as
		one of the possible applications of this language.  The language should
		vaguely resemble configuration files in use today and it should
		be possible to use it as command line syntax.
	
=== Syntax ===
   
   WS       ::= (' ' | '\t' | '\r' | '\n' | '#' [^\r\n]*)*
   String   ::= '"' ([^"] | '""')* '"' | "'" ([^'] | "''")* "'" | [^ \r\n\t#={}'"]+
   Node     ::= String? [WS? '{' Children '}' | WS? '=' WS? Node]
   Document ::= WS? (Node WS?)*

=== Dicussion ===

The syntax was inspired by the following languages or technologies:
XML, JSON, XAML, C#, CSS, getopt

JSON - Good alternative to XML.  It is basically data structure of nested arrays
	and maps.  It is usually less verbose then XML, but in some cases it might
	actually be more verbose because all strings have to be quoted.
	The are parsers available for many languages.  It is suits your needs,
	I recommend it.
	
XAML - XAML is format for storing GUI layout in XML.  It is often more verbose
	then it needs to be and the authors of XAML have tried to solve the problem
	using a few tricks.  For example, you can express an attribute as
	Name = "{Binding Path=Source}".  Seeing this has motivated me to seek
	a language that could express something like this natively.
	
C# - C# is able to express some object-constructing expressions quite
	succinctly.  For example:  button = new Button("Hi") { FontSize = 12 };
	The next version of C# will allow:  button = MakeButton("Hi", FontSize:12);

About

Data-centric alternative to XML which is suitable for configuration files


Languages

Language:C# 100.0%