PDA

View Full Version : Custom expression evaluation in Qt



nuliknol
2nd January 2017, 21:01
I have to evaluate a simple expression introduced by the user into the search box, with following elements:


Basic logical operators: AND and OR (with optional parenthesis)
Basic arithmetic operators > , < , =
My own variables (fields)


This is for a custom "search query language", the input will be a high level query, output will be an SQL query.

Does Qt has something that would help me , like a Qt Class parsing an expression in a custom format? If not , what libraries would you recommend me to use for this task?

TIA
Nulik

d_stranz
2nd January 2017, 21:51
You should google for "expression tree" - lots of code out there. As far as Qt is concerned, possibly QRegularExpression and the QStateMachine framework would help you in building the parser.