Answer the question
In order to leave comments, you need to log in
Are there any libraries or tools for creating/modifying/processing complex business rules in php or java?
In a working project, you need to implement complex business logic based on logical rules (or, and, like, in .... etc.)
You need to create a rule in the user interface, that is, they are dynamic. Then a certain array of data needs to be run through each rule. And perform the action corresponding to this rule in case of a positive result.
Are there any tools or examples of how to implement such a task in php/java?
Example there is an array:
name=Alexander,
surname=Ivanov
age=23
from=Tver,
cars=honda, vaz
there is a set of rules:
Rule 1 : name=Alexander AND age<=20 if the rule is passed "send to the client"
Rule 2 : name= Vasya OR cars in('vaz') if the rule is passed "
rule 3 : (age=23 AND from=Moscow) OR name=Kolya if the rule is passed, edit the array and save
...
Answer the question
In order to leave comments, you need to log in
Implemented such a thing using ANTLR . It was ANTLR that was used to describe the grammar. It also generates parsers / lexers for this grammar (in the target language, we used Java as such).
Then you will need to implement your visitor for the AST tree (which will be built on the basis of the grammar you described), which will actually give you true or false of the entire expression.
It is not difficult to describe the grammar (there are examples of various grammars on the Internet), it is also easy to implement visitor.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question