010308-1

A search engine accepts queries using Boolean conditions containing the operators AND, OR, NOT, NEAR, and parethesises. Search words can be specified with double apostrophes (") around them to specify exact match, or any word except upper-case AND-OR-NOT-NEAR to specify non-exact match. Example:
Apple OR (orange AND NOT (banana OR "Hans Bergman"))
Write an ABNF a specification of the allowed syntax for queries to this search engine.

Answer

query = query / ( "(" query ")" )
( query "AND" query )
( query "OR" query ) /
( query "NEAR" query ) /
( NOT query ) / term

term = string / (""" string """)

string = *CHAR

CHAR = %x01-FF ; any character

List of exam questions