I want to parse a filter string similar to the following:
((Field1 = 'red') and (field2 = 2)) or (Field3 between 1 and 5) or (field4 in ['up', 'down'])
I’d like to use the TParser in the Classes unit, but there does not seem to be much documentation or examples on it.
TParser is used by IDE to parse DFM files into a binary format (ObjectTextToBinary). To my knowledge it only recognizes 5 tokens: (EOF, Symbol, String, Integer, Float). It is not general enough, but built for a special purpose. You would have to subclass it and change it’s implementation for your needs. My opinion is that it’s better to just write your own class/automata for your specific purpose. (It’s not even a parser but a lexical tokeniser).