title: Expression parser for Predicates in JPA
body: <p>In a command line based application I want to offer basic support for filtering database results. For this, I need to parse user input. I want to support these tokens:</p>
  
  <ul>
  <li>boolean (logical) operators including <code>and</code>, <code>or</code>, <code>not</code> and parentheses</li>
  <li>variables, strings, dates and numbers</li>
  <li>comparison Operators: <code>=</code>, <code>!=</code>, <code>&lt;</code>, <code>&gt;</code>, <code>&gt;=</code>, <code>&lt;=</code></li>
  </ul>
  
  <p>So an input string could look like this:</p>
  
  <p><em>(age > 3 or name != 'tom') and city='london' and ((birthday=01.01.2010 or birthday >= 01.01.2013))</em></p>
  
  <p>Basic stuff.</p>
  
  <p><strong>Question</strong>: Where do I get a (tokenizer and) parser for that?</p>
  
  <ul>
  <li>Are there libraries supporting these basics already?</li>
  <li>If not, I know that there are tools to generate Java classes for Tokenizers and Parsers. Do you have any recommendations?</li>
  </ul>
  
  <p>I would then convert the results to JPA's <code>Predicate</code>s for the <code>CriteriaQuery</code>. First I thought, I could just offer JPQL in command line and let the user specify SQL based restrictions. But I don't want to let the user write conditions that might stop working e. g. when the database schema changes.</p>