Re: Writing a Boolean Statement Parser/Engine - Need help
- From: "Paul Engel" <paul.engel@xxxxxxxxxxxx>
- Date: Wed, 23 Apr 2008 16:02:36 -0400
I'm not sure I'm following you. Do you have some code that illustrates this?
"Ulrich Korndoerfer" <ulrich_wants_nospam@xxxxxxxxxxxx> wrote in message
news:%23E0VqUXpIHA.548@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
Paul Engel wrote:
I need to write a boolean search string parser/engine for a scripting
project. In a perfect world:
- A user could enter a properly formatted boolean search string that I
could pass to the parser. For example, they could enter "((wallace OR
walters) AND (fire AND truck)) ANDNOT (water OR wet OR foam)".
- When I passed it to the parser, the parser would return some type of
collection (array, collection, etc.).
- I would iterate through the collection checking each term to see if it
was in the search string and return a similar collection w/ a series of
True/False values.
- The engine would look at the values I returned against the initial
search boolean, and return a collective True or False.
Has anyone written or encountered any or all of the functionality? Would
this be a good regular expression project? If so, does anyone have some
samples they could share?
I currently write an expressions evaluator, which takes a string and
evaluates it. It returns a variant value that is the value of the
expression.
The expressions use a syntax nearly compatible to VB and the evaluator
allows the user to set variables.
So eg
"(($wallace OR $walters) AND ($fire AND $truck)) AND NOT ($water OR $wet
OR $foam)"
returns True or False, depending on the values of the variables $* the
user has set.
When finished (may take one or two weeks), you can download it from my
website.
Otherwise there are some parsers outside in the web.
You could try www.datenhaus.de/Downloads/dh_Parser.zip from Olaf Schmidt,
which is able too to evaluate such expressions.
If you don't mind the extra work, you could write your own parser using
the GOLD parser engine from http://www.devincook.com/goldparser/
It uses an LALR algorithm and has an engine that builds state tables from
the syntax provided in BNF. It includes a VB6 dll that then is able to use
the state tables to parse your scripts.
--
Ulrich Korndoerfer
VB tips, helpers, solutions -> http://www.proSource.de/Downloads/
.
- Follow-Ups:
- Re: Writing a Boolean Statement Parser/Engine - Need help
- From: Ulrich Korndoerfer
- Re: Writing a Boolean Statement Parser/Engine - Need help
- References:
- Writing a Boolean Statement Parser/Engine - Need help
- From: Paul Engel
- Re: Writing a Boolean Statement Parser/Engine - Need help
- From: Ulrich Korndoerfer
- Writing a Boolean Statement Parser/Engine - Need help
- Prev by Date: Re: 64 bit program
- Next by Date: Re: I hate bottom posting!!!!!!!!!!!
- Previous by thread: Re: Writing a Boolean Statement Parser/Engine - Need help
- Next by thread: Re: Writing a Boolean Statement Parser/Engine - Need help
- Index(es):
Relevant Pages
|