X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=parser%2Fgrammar;h=7c34096e3bdb10aaee6557185dcca6c60fb6d893;hb=fc9a4ef6e9dcde7e48ca54609ba7c9e80a1f20a7;hp=17d3098324c6117c5c509a4c27ece95030766876;hpb=2167fc0e09f4343c0fe67c8c754e29a41769e684;p=phdru.name%2Fcgi-bin%2Fblog-ru%2Fsearch-tags.git diff --git a/parser/grammar b/parser/grammar index 17d3098..7c34096 100644 --- a/parser/grammar +++ b/parser/grammar @@ -3,12 +3,15 @@ # 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, TAG & TAG - search blog posts that contain both tags; +# 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: +# Parentheses are allowed to group expressions; for example: # TAG & (TAG | TAG) # !(TAG | TAG) -# and so on. This is a simple version of the grammar and it allows +# Allowed operators: conjunction - & && +# disjunction - | || +# negation - ! +# 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. @@ -23,8 +26,13 @@ NOT_OP : '!' SP1 : '[ \t]+' expression : NAME - | expression AND_OP AND_OP expression - | expression AND_OP expression - | expression OR_OP expression - | NOT_OP expression - | '(' expression ')' + | expression SP0 AND_OP AND_OP SP0 expression + | expression SP0 AND_OP SP0 expression + | NOT_OP SP0 expression + | expression SP0 OR_OP OR_OP SP0 expression + | expression SP0 OR_OP SP0 expression + | '(' SP0 expression SP0 ')' + +SP0 : SP1 | empty + +empty :