From: kai.grossjohann@gmx.net (Kai Großjohann)
Subject: Re: Fledgling project nnsearch.el
Date: Sun, 24 Aug 2003 18:57:18 +0200 [thread overview]
Message-ID: <84znhz3sep.fsf@slowfox.is.informatik.uni-duisburg.de> (raw)
In-Reply-To: <848ypj5cjg.fsf@slowfox.is.informatik.uni-duisburg.de>
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.
next prev parent reply other threads:[~2003-08-24 16:57 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-24 14:29 Kai Großjohann
2003-08-24 14:57 ` Kai Großjohann
2003-08-24 16:57 ` Kai Großjohann [this message]
2003-08-24 17:22 ` Kai Großjohann
2003-08-24 20:54 ` Juha Autero
2003-08-25 19:49 ` Kai Großjohann
2003-08-24 20:53 ` Christoph Conrad
2003-08-25 19:55 ` Kai Großjohann
2003-08-25 20:25 ` Kai Großjohann
2003-08-26 9:44 ` Christoph Conrad
2003-08-25 1:33 ` gnus-namazu.el (was: Fledgling project nnsearch.el) TSUCHIYA Masatoshi
[not found] ` <odbruc1ez6.fsf@horse08.daimi.au.dk>
2003-09-10 2:38 ` gnus-namazu.el TSUCHIYA Masatoshi
[not found] ` <ugllsweu06.fsf@horse03.daimi.au.dk>
2003-09-11 1:31 ` gnus-namazu.el TSUCHIYA Masatoshi
2004-05-01 2:43 ` gnus-namazu.el in gnus/contrib? TSUCHIYA Masatoshi
2004-05-01 19:39 ` Kai Grossjohann
2004-05-03 10:24 ` Stefan Reichör
2004-05-11 6:17 ` TSUCHIYA Masatoshi
2004-05-11 8:51 ` Reiner Steib
2004-05-11 9:07 ` TSUCHIYA Masatoshi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=84znhz3sep.fsf@slowfox.is.informatik.uni-duisburg.de \
--to=kai.grossjohann@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).