[prev in list] [next in list] [prev in thread] [next in thread]
List: imap
Subject: Re: How to parse Incoming Client Requests?
From: Abhijit Menon-Sen <ams () wiw ! org>
Date: 2004-01-16 19:52:13
Message-ID: 20040117011013.A25560 () lustre ! dyn ! wiw ! org
[Download RAW message or body]
At 2004-01-16 11:33:31 +0100, antonio@stueber.de wrote:
>
> But now I've got recursive Rules and I'm not shure if I can reproduce
> them using constants respectively in Regular Expressions.
Which "recursive rules" are you talking about?
> So those who had the same Problem parsing the incoming requests maybe
> could tell me, if Regular Expressions are a good way, or making to
> much problems.
I'd strongly recommend against trying to parse IMAP requests solely with
regular expressions. To cite just one obvious problem, you need to parse
arbitrarily-nested SEARCH expressions, and a regular expression can't do
that.
> Maybe there's a better way. I'm not shure how to handle the incoming
> messages.
Why not just write a simple recursive-descent parser by hand? You could,
for example, write functions to remove each type of token from the input
string, and then write things like:
if ( command() == "RENAME" )
parse_rename();
...
parse_rename( char **src, char **dst )
{
space(); // Eat a space after the command name.
src = astring(); // Eat a mailbox name.
space(); // ...
dst = astring();
}
With suitable (simple) error handling, and translated to the language of
your choice. The grammar is small enough for this to be both easy to do,
and to maintain.
-- ams
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic