# Grammar rules for tag searching # 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 # Usual priority: NOT recognized before AND, AND before OR. # This is a simple version of the grammar and it allows # rather stupid expressions, like (TAG) or ((TAG)) or !(!(TAG)). expression = or_expression / aterm_expression or_expression = aterm_expression or_op expression and_expression = term_expression and_op aterm_expression not_expression = not_op space0 (parens_expression / name) aterm_expression = and_expression / term_expression term_expression = not_expression / parens_expression / (name space_b4letter) parens_expression = "(" space0 expression space0 ")" and_op = (space0 ("&&" / "&") space0) / (space0 ("AND" / "and") space_b4letter) or_op = (space0 ("||" / "|") space0) / (space0 ("OR" / "or") space_b4letter) not_op = (space0 "!" space0) / (space0 ("NOT" / "not") space_b4letter) letter = ~"[a-z]"i name = ~"[a-z][a-z0-9_]*" space_b4letter = (space1 &letter) / space0 space0 = ~" *" space1 = ~" +" # vim: set ft=text :