building a tree structure from logical expressions using jparsec

256 Views Asked by At

I do have expressions like

({123} AND {456} AND {789}) OR NOT {111}

The strings with the curly braces (e.g. {123}) are references to items in a basket. The boolean logic determines if a current basket is valid. The expressions can have an arbitrary nesting depth. In the example the basket is considered valid if either 123, 456 and 789 or not item 111 are in the basket as well.

Using jparsec I want to build an object tree representing the logic - don't need the execution of logic here already.

Unfortunately I failed to completly understand the examples at https://github.com/jparsec/jparsec/wiki/Overview and https://github.com/jparsec/jparsec/wiki/Tutorial in a way to write my own code for that (rather simple) problem. I always get stuck with an error message saying:

org.codehaus.jparsec.error.ParserException: Parser not on token level

What is the reason for this exception?

I'd appreciate some sample code showing how to create a parser for the above sketched expressions.

0

There are 0 best solutions below