UDL core language updates

There were some features missing from the original UDL core language that I wanted to address. Some of the new features include keys with no values and quoted names for key and section names. However, the most important new feature is an new syntax for specifying key values over multiple lines.

Previously, if you wanted a key with 100 values you had to put them all on one line. This is both inconvenient to write out and hard to read. The simple and elegant solution is the addition of a multi-line key syntax. In this example both definitions of the key ‘data’ are equivalent.

[example "some name"]
{
  UseSystemMemory
  "Key String" "some string"
  data 1 2 3 4 5 6 7 8 9 0 11 12 13 14 15
  data
  {
     1  2  3  4  5
     6  7  8  9 10
    11 12 13 14 15
  }
}

Originally, I had been considering introducing a new type beyond keys and sections for specifying large amounts of data. This would have required a completely new data type, complicating the language and resulting API. Multi-line key syntax only requires a change to the parser. In addition any key can be specified on multiple lines using this syntax if it’s convenient for the user.

With these updates the grammar of UDL is now:

file        : sections
            | empty

sections    : section
            | section sections

section     : "[" value value "]" NEWLINE "{" statements "}" NEWLINE

statements  : statement
            | statement statements

statement   : section
            | keys

key         : value NEWLINE
            | value values NEWLINE
            | value NEWLINE "{" value_lines "}" NEWLINE

values      : value
            | value values

value_lines : values NEWLINE
            | values NEWLINE value_lines

value       : NAME
            | STRING

Leave a Reply