This is my disclaimer for a long and ugly post, also I'm obviously not trying to make a replacement for xml, just an alternative I can use and others if I decide my stuff isn't too ........ty to put up somewhere.
The xml thing gave me a very good idea. I've always hated xml, I find it cluttered and difficult to read, I slapped together something very similar to xml in idea but very different in syntax.
Structural Component Descriptions will define (obviously) the structure of configuration files much like dtd's do in xml.
I hacked together what that part of the language will look like, I would appreciate input from you all (syntactic and functional):
Code:
SDC ::= header SCD_construct+
header ::= SCD_global_descriptor
SCD_global_descriptor ::= '[+scd]' ('{' version scd_version scd_name '}' | version scd_version scd_name)
version ::= num '.' num
SCD_construct ::= cname (enum_construct | structure_construct)
enum_construct ::= '=' edescriptor ('|' edescriptor)*
edescriptor ::= [_A-Za-z][_A-Za-z0-9]*
structure_construct ::= '{' (presence_modifier? type_check? fieldname ('=' fvdefault)? fterminator)+ '}'
presence_modifier ::= '?' | '+' | '*' | '['num '-' num? ']'
type_check ::= native or defined type names separated by commas
fieldname ::= [_A-Za-z][_A-Za-z0-9]*
fvdefault ::= value which is valid for this type (if a typecheck exists)
fterminator ::= ',' | ';' | '\n' | '\r'
type_check makes sure that the type used in the configuration file matches one of the types specified, otherwise any type is valid. Native types will be integral, floating point, and string. presence_modifier will state how many times the field can or must exist in the configuration file.
I also have the binary form layed out but this is already a fat post.
And finally an example scd
Code:
[+scd]
version=0.1
scd_name="sample scd"
scd_version=1
aWindow { ?integral x = 100, ?integral y = 100;
*string child
width; float height
[19-]something_else}
apart = PART_ONE | PART_TWO | PART_SIX
If an aWindow appears in the configuration file then it may or may not define x and y, it can define zero or more instances of child, must define width and height, and 19 or more instances of something_else. if an apart appears then it's value can only be PART_ONE PART_TWO or PART_SIX.
I haven't layed out the configuration files yet but I plan on making them pretty flexible, not just C89 or C99 structure definitions in any case.
Please--even if you wouldn't use something like this, give me input so I can make it easier, cleaner, and better. It's a first rough draft and I would like to produce something reuseable.