# Grammar rules for tag searching; EBNF. # The grammar defines expressions in the following forms: # TAG - search blog posts that contain the tag; # !TAG - search blog posts that don't contain the tag; # TAG & TAG - search blog posts that contain both tags; # TAG | TAG - search blog posts that contain any of the tags; # Parentheses are allowed to group expressions; for example: # TAG & (TAG | TAG) # !(TAG | TAG) # Allowed operators: conjunction - & && AND and # disjunction - | || OR or # negation - ! NOT not # This is a simple version of the grammar and it allows # rather stupid expressions, like !!TAG or ((TAG)) @@grammar :: Tags start = expression $ ; expression = ( | expression and_op expression | expression or_op expression | not_op expression | expression_parens | name ) ; expression_parens = '(' expression ')' ; name = /[a-z][a-z0-9_]+/ ; and_op = '&' | '&&' | 'AND' | 'and' ; or_op = '|' | '||' | 'OR' | 'or' ; not_op = '!' | 'NOT' | 'not' ;