/* demo.conf - v0.1.3
- a configuration file to demonstrate all of the spconfig features */
# --------
# comments
# --------
/* this is a block comment */
/* slash-star comments can
occupy multiple lines. */
// this is another type of comment: a line comment
# so is this
/* nested block /* comments */ are honoured */
## this "nested" line comment is the same as a single
// same here // etc
so this text is in fact assigned to the root node (more on this later)
// things like this cause /* confusion, but they
actually */ work. this text is still a comment; haven't yet reached a newline
some additional root-level text
# -----
# nodes
# -----
# nodes are conceptual groups, probably most analagous to html/xml "tags".
# each node has a name, and can have "attributes" and "text"
# nodes begin like this:
# node names do not need to be unique:
# and nodes end like this:
# when no nodes are 'open', such as here, the scope is known as the 'root'
# node, which collects all text outside of all nodes, and is the parent of
# all unnested nodes.
# it's also possible to have a node "self-terminate":
# you can end a node with just a slash:
>
# but ending with the name specified allows for an additional level of errorchecking:
# in this case, the parser will produce an error message,
# complaining that "/foo" does not close "bar",
# and will assume that it is meant to.
> # clean things up (this will close "foo")
# nodes can have "attributes", again, like html/xml:
# quotes are optional, unless you want to include spaces.
# values are assumed to be numerical at first, until a nonnumerical
# character (other than decimal, plus, or minus) is encountered,
# at which point it becomes a string.
# when in a node, comments are ignored when within quotes, as
# demonstrated by the following:
<"/*Node with comments in quotes" "//comment"="#/*foo*///bar" />
# attributes can also have no value:
# nodes can be nested:
>
>
>
>
>
# or
>>
# nodes have "text" associated with them, which is all of the data
# that is not a comment, a child node beginning/end, or inside a child node.
# this data is concatenated into a single string.
this text is in node1, a child node of rootnode
# a more complex example:
this text belongs to branch1.>
branch2's text.>
branch3's text is split
in twig1, but not in branch3.>
between
>
its children.
>
# when text appears outside all nodes, it is assigned to the root node, like this:
root node text.
# ---------------
# system commands
# ---------------
# this will add a message to the message list (with which the main program can
# do as it likes).
[notice this is a sample notice]
# it can occur at any level:
[notice within a node]
# it will become more useful once conditionals and includes are implemented.
# ------
# escape
# ------
# backslash is used to "escape" special characters so that they can be treated
# as normal text.
# if you'd like to include a "<" in text:
\
# if you'd like to include a quote in a node name, attribute name, or attribute value:
<"a node called \"foo\"" "\"bar\""=0 baz="a \"quote\" here too." />
# when in quotes, "<" and ">" do not need to be escaped:
<"\" escaped\" string[] name"/>
# all these nodes have the same name
bared/>
<"foo>bared"/>
<"foo\>bared"/>
# to use a backslash, insert a doublebackslash:
# this will have the name "foo\"
<"c:\\an\\annoying\\dos\\directory\\" />
# backslashes don't matter in comments.
# the name of this next node will be "node<3>"
# because "<" isn't special when inside a node definition
value1=42 value2=+3.1415926 value3="this value is a string">
this text is in node\<3>, a node with angle brackets in its name
>
# "we give you enough escaping flexibility to make you go blind."(TM)
# many include files can be specified in a single include directive
[include sample.include sample.include]
# or, you can just have one
[include sample.include]
# info is another type of system directive. it can be used for
# non-critical information passing, or anything the program wants.
[info position check]
# now for some more system directive fun! #
# defines work just like C. the first string, up to white space, is
# the defined value. whatever comes after the whitespace is its value
[define foo]
[define bar]
[define foobar blah]
# we can undefine values too
[undef bar]
# and check them
[ifdef bar]
[info bad, bar should't be defined!]
[else]
[info good, else works and ifdef and undef do too!]
[endif]
[info got out of failed check properly]
[ifdef foo]
[info pass, foo is defined]
[endif]
# and even see if they match another string
# matches are case sensitive, and don't require quotes unless
# the string contains spaces or ']'.
[ifneq foobar BLAH]
[info ifneq pass]
[ifneq foobar baz]
[info nested ifneq's seem ok]
[else]
[error else is broken!]
[endif]
[endif]
[ifndef undefined]
[info undefined pass]
[endif]
# directives can be nested as well
[ifdef foo]
[ifndef bar]
[info nested directives work]
[endif]
[endif a cool feature to endifs is that the stuff after it is ignored, so you can indicate what
exactly you are endif'ing :)]
# a few different non-base 10 number syntaxes are supported;
# 0x prefix for hex, 0b prefix for binary,
# (0x1234abcd, 0b1011)
# and
# h suffix for hex, b suffix for binary.
# (1234abcdh, 1011b)
# here we test some non-base 10 values: