    QueryExpression   := ZettelList? QueryDirective* SearchExpression ActionExpression?
    ZettelList        := (ZID (SPACE+ ZID)*)?.
    ZID               := '0'+ ('1' .. '9'') DIGIT*
                       | ('1' .. '9') DIGIT*.
    QueryDirective    := ContextDirective
                       | ThreadDirective
                       | IdentDirective
                       | ItemsDirective
                       | UnlinkedDirective.
    ContextDirective  := "CONTEXT" (SPACE+ ContextDetail)*.
    ContextDetail     := "FULL"
                       | "BACKWARD"
                       | "FORWARD"
                       | "DIRECTED"
                       | "COST" SPACE+ PosInt
                       | "MAX" SPACE+ PosInt
                       | "MIN" SPACE+ PosInt.
    ThreadDirective   := ("FOLGE" | "SEQUEL" | "THREAD") (SPACE+ ThreadDetail)*.
    ThreadDetail      := "BACKWARD"
                       | "FORWARD"
                       | "DIRECTED"
                       | "MAX" SPACE+ PosInt.
    IdentDirective    := IDENT.
    ItemsDirective    := ITEMS.
    UnlinkedDirective := UNLINKED (SPACE+ PHRASE SPACE+ Word)*.
    SearchExpression  := SearchTerm (SPACE+ SearchTerm)*.
    SearchTerm        := SearchOperator? SearchValue
                       | SearchKey SearchOperator SearchValue?
                       | SearchKey ExistOperator
                       | "OR"
                       | "RANDOM"
                       | "PICK" SPACE+ PosInt
                       | "ORDER" SPACE+ ("REVERSE" SPACE+)? SearchKey
                       | "OFFSET" SPACE+ PosInt
                       | "LIMIT" SPACE+ PosInt.
    SearchValue       := Word.
    SearchKey         := MetadataKey.
    SearchOperator    := '!'
                       | ('!')? ('~' | ':' | '[' | ']').
    ExistOperator     := '?'
                       | '!' '?'.
    PosInt            := '0'
                       | ('1' .. '9') DIGIT*.
    ActionExpression  := '|' (Action (SPACE+ Action)*)?
    Action            := Word
                       | 'KEYS'
                       | 'N' NO-SPACE*
                       | 'MAX' PosInt
                       | 'MIN' PosInt
                       | 'REDIRECT'
                       | 'REINDEX'.
    Word              := NO-SPACE+