]> git.phdru.name Git - phdru.name/cgi-bin/blog-ru/search-tags.git/blobdiff - parser/grammar
Change handling of spaces
[phdru.name/cgi-bin/blog-ru/search-tags.git] / parser / grammar
index ade8b129eceb5b65576ee8edca20a6308fe2a09f..7c34096e3bdb10aaee6557185dcca6c60fb6d893 100644 (file)
@@ -4,13 +4,16 @@
 #  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;
-# Parentheses are allowed to group expressions:
+#  TAG | TAG - search blog posts that contain any of the tags;
+# Parentheses are allowed to group expressions; for example:
 #  TAG & (TAG | TAG)
 #  !(TAG | TAG)
-# and so on. This  is the first 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 stricter and more complex.
+# it will be fixed by making the grammar more complex and stricter.
 
 NAME : '[a-z][a-z0-9_]+'
 
@@ -20,13 +23,16 @@ OR_OP : '|'
 
 NOT_OP : '!'
 
-SP0 : '[ \t]*'
-
 SP1 : '[ \t]+'
 
 expression : NAME
-           | expression AND_OP expression
-           | expression OR_OP expression
-           | NOT_OP expression
-           | '(' expression ')'
-           | SP0 expression SP0
+           | 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 :