|Devising a grammar for boolean queries email@example.com (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 firstname.lastname@example.org (Joachim Durchholz) (2000-11-01)|
|Re: Devising a grammar for boolean queries email@example.com (Randall Hyde) (2000-11-01)|
|From:||Bemmu Sepponen <firstname.lastname@example.org>|
|Date:||31 Oct 2000 14:37:19 -0500|
|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:
"foo bar" or
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
Search the comp.compilers archives again.