X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=parser%2Fgrammar;h=0017a96479b35acc8e1b1962e63f8844850668a2;hb=9d22f4f705db6a30fa2d49fdc074b901ec3cb3dc;hp=ade8b129eceb5b65576ee8edca20a6308fe2a09f;hpb=47606d9636fd6076cee67d444207aa66d30abfbe;p=phdru.name%2Fcgi-bin%2Fblog-ru%2Fsearch-tags.git diff --git a/parser/grammar b/parser/grammar index ade8b12..0017a96 100644 --- a/parser/grammar +++ b/parser/grammar @@ -3,14 +3,14 @@ # 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 - search blog posts that contain both tags; -# TAG | TAG - search blog posts that contain one of the tags or both; +# TAG && TAG, TAG & TAG - search blog posts that contain both tags; +# TAG || TAG, TAG | TAG - search blog posts that contain any of the tags; # Parentheses are allowed to group expressions: # TAG & (TAG | TAG) # !(TAG | TAG) -# and so on. This is the first version of the grammar and it allows +# and so on. 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 stricter and more complex. +# it will be fixed by making the grammar more complex and stricter. NAME : '[a-z][a-z0-9_]+' @@ -20,13 +20,12 @@ OR_OP : '|' NOT_OP : '!' -SP0 : '[ \t]*' - 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 ')' - | SP0 expression SP0