syntax include @Awk syntax/awk.vim
syntax region AatAwk keepend oneline start="^|" end="$" contains=@Awk,AatBar
syntax region AatAwk keepend start="{{" end="}}" skip=/"[^"]*}}[^"]*"/ contains=@Awk,AatCurly
syntax region AatAwk keepend start="{%" end="%}" skip=/"[^"]*%}[^"]*"/ contains=@Awk,AatBar
syntax region AatQuery keepend start="{<" end=">}" contains=@AatQuery

syntax match AatCurly contained /{{\|}}/
syntax match AatPercent contained /{%\/%}/
syntax match AatBar contained /^|/
syntax match AatAngle contained /{<\|>}/

syntax match AatMacro /^@[^@].*$/

" number literal
syntax match AatNumber contained /^[0-9]x?[0-9a-fA-F.]+(e[-+][0-9]+)?/
" a query
syntax match AatVariable contained /^[a-zA-Z_.<>'][a-zA-Z0-9_.<>']*/
" filters ahead
syntax match AatFilter contained /^|[a-zA-Z][a-zA-Z0-9_]*/
" literal string
syntax match AatString contained /^"([^"\\]\|\\[^"])*"/

syntax cluster AatQuery contains=AatAngle,AatNumber,AatVariable,AatFilter,AatString

highlight link AatMacro Macro
highlight link AatCurly Statement
highlight link AatPercent Statement
highlight link AatBar Statement
highlight link AatAngle Statement

highlight link AatNumber Number
highlight link AatVariable Identifier
highlight link AatFilter Operator
highlight link AatString String