Overpass QL finally gets a formal grammar, verified against the source code
Overpass QL EBNF Grammar

A W3C EBNF grammar for Overpass QL, the query language behind OpenStreetMap's Overpass API, written in the same notation as the XML 1.0 spec. It's meant for generating and validating queries and for browsing the language through railroad diagrams. Because the official docs aren't always reliable, the author checked the grammar against the Overpass API source and tested it on a live v0.7.62.11 instance, excluding undocumented features.
Please do not use this grammar to abuse public Overpass servers by sending large volumes of automated queries.