X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=parser%2Fgrammar;h=14753c88e28544d5252a74dc38a142fc11e20d83;hb=c86096298aca4aae4135535920bcfc68633f45b3;hp=5a0c3d53a1a9c8d5f5d270804ed7f3150e0637bc;hpb=39c76ea424261b4abf153916f48eef13315e0e83;p=phdru.name%2Fcgi-bin%2Fblog-ru%2Fsearch-tags.git diff --git a/parser/grammar b/parser/grammar index 5a0c3d5..14753c8 100644 --- a/parser/grammar +++ b/parser/grammar @@ -8,9 +8,9 @@ # Parentheses are allowed to group expressions; for example: # TAG & (TAG | TAG) # !(TAG | TAG) -# Allowed operators: conjunction - & && -# disjunction - | || -# negation - ! +# 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. @@ -26,9 +26,37 @@ NOT_OP : '!' SP1 : '[ \t]+' expression : NAME - | expression AND_OP AND_OP expression - | expression AND_OP expression - | expression OR_OP OR_OP expression - | expression OR_OP expression - | NOT_OP expression - | '(' expression ')' + | expression SP0 AND_OP AND_OP SP0 expression + | expression SP0 AND_OP SP0 expression + | l_expression and_word r_expression + | expression SP0 OR_OP OR_OP SP0 expression + | expression SP0 OR_OP SP0 expression + | l_expression or_word r_expression + | NOT_OP SP0 expression + | not_word r_expression + | expression_parens + +l_expression : expression_parens + | expression_sp + +r_expression : expression_parens + | sp_expression + +expression_parens : '(' SP0 expression SP0 ')' + +sp_expression : SP1 expression + +expression_sp : expression SP1 + +and_word : 'A' 'N' 'D' + | 'a' 'n' 'd' + +or_word : 'O' 'R' + | 'o' 'r' + +not_word : 'N' 'O' 'T' + | 'n' 'o' 't' + +SP0 : SP1 | empty + +empty :