From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/53804 Path: main.gmane.org!not-for-mail From: kai.grossjohann@gmx.net (=?iso-8859-1?q?Kai_Gro=DFjohann?=) Newsgroups: gmane.emacs.gnus.general Subject: Re: Fledgling project nnsearch.el Date: Sun, 24 Aug 2003 18:57:18 +0200 Organization: University of Duisburg, Germany Sender: ding-owner@lists.math.uh.edu Message-ID: <84znhz3sep.fsf@slowfox.is.informatik.uni-duisburg.de> References: <841xvbb03m.fsf@slowfox.is.informatik.uni-duisburg.de> <848ypj5cjg.fsf@slowfox.is.informatik.uni-duisburg.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1061744307 12017 80.91.224.253 (24 Aug 2003 16:58:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 24 Aug 2003 16:58:27 +0000 (UTC) Original-X-From: ding-owner+M2344@lists.math.uh.edu Sun Aug 24 18:58:25 2003 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19qyC9-0005Th-00 for ; Sun, 24 Aug 2003 18:58:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 19qyBE-0002vZ-00; Sun, 24 Aug 2003 11:57:28 -0500 Original-Received: from sclp3.sclp.com ([64.157.176.121]) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 19qyB7-0002vT-00 for ding@lists.math.uh.edu; Sun, 24 Aug 2003 11:57:21 -0500 Original-Received: (qmail 79056 invoked by alias); 24 Aug 2003 16:57:20 -0000 Original-Received: (qmail 79051 invoked from network); 24 Aug 2003 16:57:20 -0000 Original-Received: from quimby.gnus.org (80.91.224.244) by sclp3.sclp.com with SMTP; 24 Aug 2003 16:57:20 -0000 Original-Received: from news by quimby.gnus.org with local (Exim 3.12 #1 (Debian)) id 19qyGF-0000IQ-00 for ; Sun, 24 Aug 2003 19:02:39 +0200 Original-To: ding@gnus.org Original-Path: not-for-mail Original-Newsgroups: gnus.ding Original-Lines: 47 Original-NNTP-Posting-Host: pd951f940.dip.t-dialin.net Original-X-Trace: quimby.gnus.org 1061744559 323 217.81.249.64 (24 Aug 2003 17:02:39 GMT) Original-X-Complaints-To: usenet@quimby.gnus.org Original-NNTP-Posting-Date: 24 Aug 2003 17:02:39 GMT Mail-Copies-To: never User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/21.3.50 (gnu/linux) Cancel-Lock: sha1:gGeSHKriEZV7x3nmeNZC2sNo6Lw= Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:53804 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:53804 It seems I'm too stupid to implement a simple parser. I thought it would be good for nnsearch.el to accept a standard query syntax, and to transmogrify these queries into things that the search engines grok. I looked at the Namazu query syntax, and I like it. It goes like this: Query ::= Term | Term "and" Query | Term "or" Query | Term "not" Query | "(" Query ")" Term ::= Word | Field ":" Word Word ::= { a string of letters } Field ::= { name of mail header } This appears to be simple enough. But my parser isn't working. I tried a recursive descent, and I'm getting weird results. So does somebody have a good design pattern that could be used to construct that kind of parser? It seems to be clear that I need a function that reads a token. Tokens are: and, or, not, open paren, close paren, colon, words and fields. (I guess that word and field can't be distinguished by the lexer.) Then it also seems to be clear that I need a function for each nonterminal in the grammar. So there will be a parse-query, a parse-term, a parse-field, and a parse-word. What should be the argument of each such function and what should be the return value? I put the string into a buffer and used point as an indication what to read next. For the lookahead I used save-excursion. The parse-* functions didn't have arguments, and the return values were (partial) parse trees. Help? -- Two cafe au lait please, but without milk.