On Mon, Nov 18, 2002 at 07:23:36AM -0800, Bill Moseley wrote:
> Or the parser needs to generate a recursive data structure with flags on
> each word to indicate things like being in a phrase.
I think a simple tree like:
enum operator {and, andnot, or, near, adjacent, leaf};
typedef struct _search_phrase {
operator o;
struct _search_phrase *left; /* only on non-leaf */
struct _search_phrase *right;
char *word; /* only on leaf */
} search_expr;
would be fine. Ie you are not flagging the individual words.
Then you can do a generate_list function:
match_list *
generate_list(search_expr *expr)
{
switch (expr->o) {
case and:
match_list *left = generate_list(expr->left);
match_list *right = generate_list(expr->right);
return(and_lists(left, right));
...
--
Erik Corry erik@arbat.com
Received on Mon Nov 18 16:02:43 2002