Versions Compared

Key

This line was added.

This line was removed.

Formatting was changed.

Overview

SDL (Simple Declarative Language) was designed to provide a terse and perspicuous format for describing common data structures and data types. Although XML is an excellent format for marking up documents, embedding in free form text, and creating graphs it can be a cumbersome language for expressing basic datastructures. SDL is particularly well suited for this purpose. Lists, maps, trees, tables, and matrixes can be easily expressed in SDL. Following is a list of examples demonstrating construction of various datastructures using typed data.

Because of its terse syntax and type inference capabilities, SDL is ideally suited to applications such as

Configuration Files

Build Files

Property Files

Simple Object Serialization

Log files (formatting and parsing)

SDL was designed to be language agnostic. Currently APIs exist for Java and .NET (written in C#.) C++, Python and Ruby ports are planned.

Tags

A tag can contain a namespace, a name, a value list, attributes (with namespaces), and children. All components are optional. If the name portion is ommited the tag name defaults to "content". Namespaces default to the empty space (""). Names and namespaces are identifiers.

Tags are written using the form:

No Format

namespace:name values attributes {
children
}

Tags are terminated with a new line (\n) or the ending bracket of a child list (}). Lines can be continued by escaping the new line like so:

No Format

values 3.5 true false "hello" \
"more" "values" 345 12:23:41

Values are space separated literals and attributes are space separated key value pairs using the format:

Anonymous Tags

Tags with no name are known as anonymous tags. They are automatically assigned the name "content".

No Format

title

Example: An Anonymous Tag

greetings {
"hello" language="English"
}
# If we have a handle on the "greetings" tag we can access the
# anonymous child tag by calling
# Tag child1 = greetingTag.getChild("content");

Info

title

Note: Anonymous tags must have at least one value

Anonymous tags must have one or more values. They cannot contain only attributes. This design decision was taken to avoid confusion between a tag with a single value and an anonymous tag containing only one attribute.

No Format

# Not allowed: An anonymous tag with a single attribute (and no values)...
size=5
# ...because it could easily be confused with a tag having a single value
size 5

note 1: hours, minutes, and seconds are required - days and milliseconds are optional

note 2: if the day component is included it must be suffixed with a lower case 'd'

binary [standard Base64] example - [sdf789GSfsb2+3324sf2]

null A literal for a null value (must be lower case) example - null

* Notes: For platforms that do not support this level of precision, decimal should resolve to the most accurate decimal representation possible.

String Literals

There are two ways to write a string literal. Double quoted literals begin and end with a double quote ("). They cannot span lines unless the new line is escaped. If the new line is escaped, all white space to the left of the first non-white space character in the next line is ignored. For example, if we write

No Format

test "john \
doe"

The test tag's value will be "john doe". The space before the escape is preserved, but the space before the "d" in "doe" is ignored. White space characters (\n\r\t ), backslashes () and double quotes (") must be escaped in double quote literals.

No Format

title

Examples: Double Quote String Literals

name "hello"
line "he said \"hello there\""
whitespace "item1\titem2\nitem3\titem4"
continued "this is a long line \
of text"

The second type of string literal is the backquote (`) literal. It functions much like Python's triple quote (""") or C#'s at quote (@""). All characters including whitespace between backquotes are preserved. It is not necessary (or possible) to escape any type of character in a backquote literal.

Date and Date/Time Literals

SDL supports date and date/time literals. Date and date/time literals use a 24 hour clock (0-23). If a timezone is not specified, the default locale's timezone will be used.

No Format

title

Examples: Date and Date/Time Literals

# create a tag called "date" with a date value of Dec 5, 2005
date 2005/12/05
# a date time literal without a timezone
here 2005/12/05 14:12:23.345
# a date time literal with a timezone
in_japan 2005/12/05 14:12:23.345-JST

Time Span Literals

SDL Time Span literals represent a length of time (which may be negative.) TimeSpan literals are useful for expressing the duration of an event, intervals, or chronological distances from a reference point.

Comments

SDL supports four comment types.

The first three are line comment types. Line comments can start with a #, //, or --. Everything between the beginning of the single line comment and the new line is ignored. The – style separator comment is often used to visually separate sections like so:

The fourth type of comment is the /* */ style multiline comment used in Java and C family languages. Everything between the /* and */ is ignored. /* */ comments may span lines and occur in the middle of lines.

SDL Files

SDL files (any file ending with the extension .sdl) should always be encoded using UTF-8. The use of unicode escaping (such as the \uxxxx format used by Java and C#) is not supported or required. Non ASCII characters should be entered directly using a UTF-8 capable editor.

Note: ASCII is transparently encoded in UTF8, so ASCII files can be used if only ASCII characters are required.