Re: grammar problems

[email protected] ((Randal L. Schwartz)) 21 May 2004 15:29:00 -0700
Newsgroups perl.recdescent
Organization Stonehenge Consulting Services; Portland, Oregon, USA
Message-ID <[email protected]>
>>>>> "Jonas" == Jonas Wolf <[email protected]> writes:

Jonas> I would like to parse boolean queries like the following:
Jonas> <=> means the two queries represent the same structure

Jonas> this and that <=> this that
Jonas> this or that
Jonas> a b or c d <=> (a b) or (c d) <=> (a and b) or (c and d)
Jonas> "this phrase" word <=> "this phrase" and word
Jonas> abstract = error or content = mistake <=> (abstract = error) or (content = 
Jonas> mistake)
Jonas> ...

I'm a bear of very little brain and you're using those fancy-schmancy
words like "conjunction" and "disjunction", but I'd structure that
as:

disjunction: <leftop: conjunction "or" conjunction>
conjunction: <leftop: atom optional_and atom>
optional_and: "and" | ""
atom: "(" disjunction ")" | equality | word | quoted_phrase
word: /\w+/
quoted_phrase: /"[^"]+"/
equality: word "=" word

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!