When we got to the development of a system of custom filters (or conditions), Misha, our main interface, hung. He looked thoughtfully out the window and smoked one by one, sometimes broke off and began to thresh on a pear, shouting something obscene. In general, he had a difficult task: at the last meeting, it was decided that forcing users to create rules in text form was inhuman and non-intuitive.
On the third day of such a pastime, Misha (
oporkov ) exclaimed: “We will have a tree!”. The solution turned out to be quite simple: to display the condition in the form of a tree, the branches of which denote a logical “and” or “or”, and the leaves - comparison operations. For several days he was looking at the monitor, pounding on the keyboard and muttering something obscene. One day he asked me how we would keep the tree, given that I was swallowed up by optimizing SQL queries, blurted out the first thing that occurred to me: “In a row”.
As a result, I considered the following:
&( s_!=~( city , " - " ) , s_=( platform , " Linux " ) , i_>( screenw , 1024 ) , i_>( screenh , 800 ) , |( i_>( viewed , 7 ) , i_>=( timeonsite , 30 ) ) )
What corresponded to such a tree:

While I was looking at this line and her sisters, the opinion that all this is similar to a programming language grew stronger in me. In the end, after several experiments, it became clear that the easiest way to do the interpreter of this language, and not to enter it into another logic. The working title was “scisp”, due to the abundance of brackets. But after some thought, they decided that it was not very suitable, because work is done more with logic, not lists. As a result, the language gained its final name "SCLOG".
')
Currently, SCLOG supports two data types (“string” and “integer”), two logical operators (“and” and “or”), four comparison operations for strings (“equal”, “not equal”, “contains”, "Does not contain"), six operations for integers ("equal", "not equal", "greater than", "less than", "greater than or equal", "less than or equal") has a visual tree-building tool written in jQuery and interpreter on php.
The line that was presented above should now look like this:
&( !~(city,"-"),=(platform ,"Linux"),>(screenw,1024),>(screenh,800),|(>(viewed,7),>=(timeonsite,30)))
Insignificant gaps disappeared, and comparison operations gained a digestible view. The tree has evolved into the following form (almost completely modifiable CSS):

What will happen next:
- New data types: logical, date-time, fractional and arrays;
- C # interpreter.
Where to look:
PS Asked to add life examples, tell you why we need it:
The user sets a rule; the main battle was just to ensure that the rules (they are filters) were created in a more understandable way than, for example, in Outlook. Trees, in our opinion, have a more visual appearance than the list of lines. Next, the constructed tree is saved as a string in the SCLOG language. Then, at the time of processing the filters, this string is interpreted on the server side and returns the value TRUE or FALSE.