-# Grammar rules for tag searching; EBNF.
+# Grammar rules for tag searching
# The grammar defines expressions in the following forms:
# TAG - search blog posts that contain the tag;
# This is a simple version of the grammar and it allows
# rather stupid expressions, like (TAG) or ((TAG)) or !(!(TAG)).
-@@grammar :: Tags
+expression = or_expression / aterm_expression
-start = expression $ ;
+or_expression = aterm_expression or_op expression
-expression = expression1 !or_op | or_expression ;
+and_expression = term_expression and_op aterm_expression
-or_expression = expression1 or_op expression ;
+not_expression = not_op space0 (parens_expression / name)
-and_expression = expression2 and_op expression1 ;
+aterm_expression = and_expression / term_expression
-not_expression = not_op expression3 ;
+term_expression = not_expression / parens_expression / (name space_b4letter)
-parens_expression = '(' expression ')' ;
+parens_expression = "(" space0 expression space0 ")"
-expression1 = expression2 !and_op | and_expression ;
+and_op = (space0 ("&&" / "&") space0) / (space0 ("AND" / "and") space_b4letter)
-expression2 = !not_op expression3 | not_expression ;
+or_op = (space0 ("||" / "|") space0) / (space0 ("OR" / "or") space_b4letter)
-expression3 = parens_expression | name ;
+not_op = (space0 "!" space0) / (space0 ("NOT" / "not") space_b4letter)
-and_op = '&&' | '&' | 'AND' | 'and' ;
+letter = ~"[a-z]"i
-or_op = '||' | '|' | 'OR' | 'or' ;
+name = ~"[a-z][a-z0-9_]*"
-not_op = '!' | 'NOT' | 'not' ;
+space_b4letter = (space1 &letter) / space0
-name = /[a-z][a-z0-9_]+/ ;
+space0 = ~" *"
+
+space1 = ~" +"
+
+# vim: set ft=text :