# 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)); in the future # it will be fixed by making the grammar more complex and stricter. ?start : expression ?expression : or_expression | and_expression | and_sub_expression or_expression : or_sub_expression (or or_sub_expression)+ ?or_sub_expression : and_expression | and_sub_expression and_expression : and_sub_expression (and and_sub_expression)+ ?and_sub_expression : not_expression | expression_parens | name not_expression: not and_sub_expression expression_parens : "(" expression ")" name : /[a-z][a-z0-9_]+/ ?and : and_op | and_op and_op | and_word ?or : or_op | or_op or_op | or_word ?not : not_op | not_word ?and_op : "&" ?or_op : "|" ?not_op : "!" ?and_word : "AND" | "and" ?or_word : "OR" | "or" ?not_word : "NOT" | "not" %import common.WS %ignore WS