hammerlab/cycledash — pull request #193 by danvk (2014-11-12 21:40:09+00:00)
Title: Parser for CQL (Cycledash Query Language)

Here are a few sample queries that it can parse
```
A < 10
B = ABC
20
20:1234-
20:-4,567
X:345-4,567
ORDER BY A
ORDER BY B DESC
ORDER BY INFO.DP ASC
A < 10 AND B >= ABC
20:1234- AND A < 10
A <= 10 and X:345-4,567 and B = ABC ORDER BY INFO.DP ASC
```

Highlights for this review:

- I used peg.js for parsing. This generates a [PEG][1] (Parsing Expression Grammar), which is like a CFG grammar that eliminates ambiguous parses by always taking the first match.
- I went with `20:1,234-4,567` as the syntax for range matching. This might fail if there's ever a contig with the same name as a column or `ORDER`. For the time being, I've hard-coded contigs to be either numbers, `X` or `Y`.
- The parser gets generated into `cycledash/static/lib`. Alternative suggestions welcome.
- This PR does nothing to integrate this into CycleDash or implement typeahead. The former is blocked, I'll look into the latter next.

[1]: http://en.wikipedia.org/wiki/Parsing_expression_grammar