# 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))
+# rather stupid expressions, like (TAG) or ((TAG)) or !(!(TAG)).
@@grammar :: Tags
start = expression $ ;
-expression = (
- | expression and_op expression
- | expression or_op expression
- | not_op expression
- | expression_parens
- | name ) ;
+expression = expression1 !or_op | or_expression ;
-expression_parens = '(' expression ')' ;
+or_expression = expression1 or_op expression ;
-name = /[a-z][a-z0-9_]+/ ;
+and_expression = expression2 and_op expression1 ;
+
+not_expression = not_op expression3 ;
+
+parens_expression = '(' expression ')' ;
+
+expression1 = expression2 !and_op | and_expression ;
-and_op = '&' | '&&' | 'AND' | 'and' ;
+expression2 = !not_op expression3 | not_expression ;
-or_op = '|' | '||' | 'OR' | 'or' ;
+expression3 = parens_expression | name ;
+
+and_op = '&&' | '&' | 'AND' | 'and' ;
+
+or_op = '||' | '|' | 'OR' | 'or' ;
not_op = '!' | 'NOT' | 'not' ;
+
+name = /[a-z][a-z0-9_]+/ ;