Clinical Quality Language
Grammar Reference
Interactive railroad diagrams for all 113 production rules of the CQL 1.5 grammar. Click any rule name on a diagram to navigate directly to its definition.
The root rule of every CQL file. A library may optionally begin with a library declaration, followed by zero or more definitions (using, include, codesystem, valueset, code, concept, parameter), then zero or more statements (expressions, contexts, functions), and finally the end-of-file marker.
The root production rules that define the overall structure of a CQL library.
Library-level declarations that introduce named artifacts such as code systems, value sets, codes, concepts, parameters, using imports, and include imports.
Grammar rules that describe CQL types, including named types, lists, intervals, tuples, and choice types.
Executable declarations within a CQL library: expression definitions, context switches, and function definitions.
The core expression grammar covering all value-producing constructs including queries, retrieves, timing operators, and arithmetic.
The individual clauses of a CQL query: source, let, with/without, where, return, aggregate, and sort.
Fundamental expression units: literals, identifiers, invocations, and selector expressions.
Inline constructor expressions for intervals, tuples, instances, lists, codes, and concepts.
Temporal and interval relationship operator phrases used in timing expressions.
Identifier and name resolution grammar including qualified identifiers and keyword identifiers.
Lexer token definitions describing the low-level character patterns for identifiers, literals, and other terminal symbols.
Grammar source: HL7 Clinical Quality Language Specification 1.5 (ANTLR4). Non-terminals link to their respective rule pages.