Layered Query Language

Formal LQL

Note: This is the formal language that was designed to be simple yet verbose. Shortcuts will be created for commonly used parts of the syntax that will simplify the process of reading and writing the queries.

White space will be insignificant in LQL, and keywords will be case insensitive. The syntax for comments will be the same as for SQL – comments will begin with two hyphens ('--') and continue to the end of the line. Case sensitivity of variables will depend on the underlying database, and case sensitivity of attributes will depend on the implementation.

Another note: This language is currently under very active development, so it is not only possible but it is likely that some of the below syntax will change. The areas most subject to change are the keywords and the Modifier production.

Formal LQL syntax

Terminal symbols

The following are keywords: select, from, as, layer, below, not, in, no, allow, order, gaps, and overlap. Additional terminal symbols include . , ( ) [ ] { } ^ $ || && = != ~ !~ and the following (defined using standard regular expressions):

identifier
[A-Za-z][A-Za-z0-9_]*
string
' ([^'\] | \\ .)* '
aliasedString
" ([^'"\] | \\ .)* "

(In a string, a backslash escapes whatever character follows it. Also, if a string is delimited by double quotes, it signifies that the value is not tested against the attribute specified by the user, but an attribute for which it is an alias.)

Non-terminal Productions

Note: the operators || and && are both left-associative, with || having a lower precedence than &&.

Query
Select 'from' Range
| 'from' Range Select
| Range Select
Select
'select' Variable '.' Attribute 'as' Variable
| 'select' Variable '.' Attribute
| Select ',' Variable '.' Attribute 'as' Variable
| Select ',' Variable '.' Attribute
Variable
identifier
Attribute
identifier
Range
AnnotationRange 'as' Variable
| AnnotationRange
| ArtificialRange
ArtificialRange
'(' ModifierStatement Ranges ')'
| '(' Ranges ')'
AnnotationRange
'[' TestWithLayer ModifierStatement '^' Ranges '$' ']'
| '[' TestWithLayer ModifierStatement '^' Ranges ']'
| '[' TestWithLayer ModifierStatement Ranges '$' ']'
| '[' TestWithLayer ModifierStatement Ranges ']'
| '[' TestWithLayer '^' Ranges '$' ']'
| '[' TestWithLayer '^' Ranges ']'
| '[' TestWithLayer Ranges '$' ']'
| '[' TestWithLayer Ranges ']'
| '[' TestWithLayer ']'
Ranges
Range
| Ranges Range
TestWithLayer
'layer' '=' Value
| TestWithLayer '&&' Test
| '(' TestWithLayer ')'
Test
Attribute TestOperator Value
| Attribute 'in' '(' ValueList ')'
| Test '||' Test
| Test '&&' Test
| '(' Test ')'
TestOperator
'='
| '!='
| '~'
| '!~'
| 'below'
| 'not' 'below'
Value
string
| aliasedString
ValueList
ValueList ',' Value
| Value
ModifierStatement
'{' Modifiers '}'
Modifier
'order'
| 'gaps'
| 'overlap'
Modifiers
'no' Modifier
| 'allow' Modifier
| Modifier
| Modifiers ',' 'no' Modifier
| Modifiers ',' 'allow' Modifier
| Modifiers ',' Modifier