X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=parser%2Fgrammar.ebnf;h=8ccdd76b4f04c87b175e43df2bdccc7f242ead06;hb=8190a22c55b953e0326dd0e577c8d042fba1fc83;hp=b657738ad5f30a6ab29508f8364b212faffa4708;hpb=3eadd8423e41b70e89854bd63e0e9875e259978c;p=phdru.name%2Fcgi-bin%2Fblog-ru%2Fsearch-tags.git diff --git a/parser/grammar.ebnf b/parser/grammar.ebnf index b657738..8ccdd76 100644 --- a/parser/grammar.ebnf +++ b/parser/grammar.ebnf @@ -12,25 +12,63 @@ # disjunction - | || OR or # negation - ! NOT not # 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)); in the future +# it will be fixed by making the grammar more complex and stricter. -@@grammar :: Tags +?start : expression -start = expression $ ; +?expression : or_expression + | and_expression + | and_sub_expression -expression = ( - | expression and_op expression - | expression or_op expression - | not_op expression - | expression_parens - | name ) ; +or_expression : or_sub_expression (or or_sub_expression)+ -expression_parens = '(' expression ')' ; +?or_sub_expression : and_expression + | and_sub_expression -name = /[a-z][a-z0-9_]+/ ; +and_expression : and_sub_expression (and and_sub_expression)+ -and_op = '&' | '&&' | 'AND' | 'and' ; +?and_sub_expression : not_expression + | expression_parens + | name -or_op = '|' | '||' | 'OR' | 'or' ; +not_expression: not and_sub_expression -not_op = '!' | 'NOT' | 'not' ; +expression_parens : "(" expression ")" + +name : /[A-Za-zá-ñÁ-ѳ£][A-Za-zá-ñÁ-ѳ£0-9_]*[A-Za-zá-ñÁ-ѳ£0-9]/ + +?and : and_op + | and_op and_op + | and_word + +?or : or_op + | or_op or_op + | or_word + +?not : not_op + | not_word + +?and_op : "&" + +?or_op : "|" + +?not_op : "!" + +?and_word : "AND" + | "and" + | "é" + | "É" + +?or_word : "OR" + | "or" + | "éìé" + | "ÉÌÉ" + +?not_word : "NOT" + | "not" + | "îå" + | "ÎÅ" + +%import common.WS +%ignore WS