1 # Grammar rules for tag searching
3 # The grammar defines expressions in the following forms:
4 # TAG - search blog posts that contain the tag;
5 # !TAG - search blog posts that don't contain the tag;
6 # TAG & TAG - search blog posts that contain both tags;
7 # TAG | TAG - search blog posts that contain any of the tags;
8 # Parentheses are allowed to group expressions; for example:
11 # Allowed operators: conjunction - & && AND and
12 # disjunction - | || OR or
13 # negation - ! NOT not
14 # Usual priority: NOT recognized before AND, AND before OR.
15 # This is a simple version of the grammar and it allows
16 # rather stupid expressions, like (TAG) or ((TAG)) or !(!(TAG)).
18 expression = or_expression / aterm_expression
20 or_expression = aterm_expression or_op expression
22 and_expression = term_expression and_op aterm_expression
24 not_expression = not_op space0 (parens_expression / name)
26 aterm_expression = and_expression / term_expression
28 term_expression = not_expression / parens_expression / (name space_b4letter)
30 parens_expression = "(" space0 expression space0 ")"
32 and_op = (space0 ("&&" / "&") space0) / (space0 ("AND" / "and") space_b4letter)
34 or_op = (space0 ("||" / "|") space0) / (space0 ("OR" / "or") space_b4letter)
36 not_op = (space0 "!" space0) / (space0 ("NOT" / "not") space_b4letter)
40 name = ~"[a-z][a-z0-9_]*"
42 space_b4letter = (space1 &letter) / space0