Related articles |
---|
Devising a grammar for boolean queries lomise@uta.fi (Bemmu Sepponen) (2000-10-31) |
Re: Devising a grammar for boolean queries nailed_barnacleSPAMFREE@hotmail.com (2000-11-01) |
Re: Devising a grammar for boolean queries joachim_d@gmx.de (Joachim Durchholz) (2000-11-01) |
Re: Devising a grammar for boolean queries rhyde@cs.ucr.edu (Randall Hyde) (2000-11-01) |
From: | Bemmu Sepponen <lomise@uta.fi> |
Newsgroups: | comp.compilers |
Date: | 31 Oct 2000 14:37:19 -0500 |
Organization: | Kissa |
Keywords: | parse, question |
Posted-Date: | 31 Oct 2000 14:37:19 EST |
I'm trying to write a parser that would form a tree out of search
engine boolean query strings. The sentences are like
"foo and (bar or buz)". "and" and "or" are the only legal operators,
there is no "not" or "xor".
I assume the precedence of "and" and "or" is the same (true?). In
addition to the operators, there can be words/phrases and parentheses.
"foo bar and (cat or dog)" should become a tree like this one:
and
/ \
"foo bar" or
/ \
"cat" "dog"
This is the first parser I've ever attempted to write. I figure the
next reasonable thing to do is form a grammar for the valid queries.
I wonder what it should be like, I'll make an attempt:
query -> phrase | phrase operator query
operator -> and | or
phrase -> word | word phrase
Am I even close? How about the parentheses?
--
Bemmu Sepponen | www.bemmu.com | BBS +358-3-3183424
[Looks OK so far. See any compilers text for some advice on
writing grammars. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.