At the heart of NLQ is a powerful libary of parser combinators which can parse partial sentences and offer suggestions for completing user input.
The other input to the system is an Entity Relationship Model. From this model and an English language knowledgebase, a parser is created using the parser combinator library.
If the parser produces an AST for the user's input, an SQL query is generated. The query is also executed to show a preview of results.
The following diagram illustrates the data flow. The whole system is implemented in Scala.