[antlr-interest] Re: Taking control of the input stream

weitzman_d weitzman_d at yahoo.com
Wed Sep 18 10:22:51 PDT 2002


--- In antlr-interest at y..., Ric Klaren <klaren at c...> wrote:
> Where you want to do this lexer or parser? It's been ages past 
since I've
> been hacking on something IMAP-ish so not sure what would 
be the most
> practical.

I suppose it would have to be the lexer, wouldn't it?  If I could 
somehow specify in a lexer token specification that I want to read 
in the next NUM characters, whatever they might be, that should 
be enough.

There might be a better way of approaching the whole problem, 
but I think I like the idea of seperating the commands from their 
syntax with a parser.  It isn't the simplest solution, but I can't
think of an alternative that's flexible and minimizes code 
repitition.

David Weitzman

> On Tue, Sep 17, 2002 at 09:23:41PM -0000, weitzman_d wrote:
> > C: A003 APPEND saved-messages (\Seen) "Date: Mon, ..."
> >
> > But servers must also be able to accept in the 'literal' form 
like
> > this:
> >
> > C: A003 APPEND saved-messages (\Seen) {310}
> > S: + continue
> > C: Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
> > C: ...
> > C: (310 bytes later...)
> > S: A003 OK APPEND completed
> >
> > I want my ANTLR grammer to see the {NUM} and eat up the 
next NUM
> > bytes into a single token.  A general outline of the rule would 
look
> > something like this:
> >
> > literal	:	"{" len:NUMBER "}" CRLF
> > 	{
> > 	int length = Integer.parseInt(len.getText());
> >         out.println("+ continue");
> > 	String value = [read the next 'length' bytes]
> > 	}
> > 	;
> >
> > How can I do this (or is it not possible)?


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



More information about the antlr-interest mailing list