title: Searching approach to evaluate domain specific expression
body: <p>I'm working on a tool in the context of a java project to evaluate a custom domain specific, rule-like expression like</p>
  
  <p><code>min-5 avg datalist &gt; Number</code></p>
  
  <p>with the individual tokens meaning the following:</p>
  
  <ul>
  <li>min-5 : optional minimum (or maximum, in that case max-5) occurences of the following term </li>
  <li>avg : an optional aggregation function which operates on the following token datalist (can also be sum or anything similar)</li>
  <li>datalist : A list of data (type: integer/ double) which will be available before the evaluation of the entire expression starts, can be reduced to a single value by the preceding aggregation function</li>
  <li>operator: conditional operator &lt; or > or =</li>
  <li>Number: value for the conditional operator</li>
  </ul>
  
  <p>Note(s):</p>
  
  <blockquote>
    <ul>
    <li>The optional amount of occurrences and the aggregation can not happen both, that would make no sense. </li>
    <li>There can be multiple of the above expressions, chained with and/or</li>
    <li>These expressions are external input, not pre-defined</li>
    </ul>
  </blockquote>
  
  <p>The evaluation of this expression should output a boolean</p>
  
  <p>As I am rather new to expression evaluation / parsing I am searching for an elegant way to solve this, possibly with a java framework/tool.</p>
  
  <p>What I've tried so far:</p>
  
  <ul>
  <li>Parsing by hand which turned out not so nicely</li>
  <li>Trying to use Janino Expression Evaluator, but I don't know how to handle this programmatically</li>
  </ul>
  
  <p>I am searching for a solution to solve this in an elegant way, I am thankful for any suggestions</p>