[Python-Dev] Re: Automatic flex interface for Python?

Greg Ewing greg@cosc.canterbury.ac.nz
Fri, 23 Aug 2002 14:38:32 +1200 (NZST)


"Eric S. Raymond" <esr@thyrsus.com>:
> Tim Peters <tim.one@comcast.net>:
> > But you lost me here -- I don't see a connection between immutability and
> > either ease of writing lexers or speed of lexers.
> It's an implementation problem.  You find yourself doing a lot of 
> string accessing and pasting, creating several new objects per
> input char.

Not necessarily! Plex manages to do it without any
of that.

The trick is to leave all the characters in the input
buffer and just *count* how many characters make up
the next token. Once you've decided where the token
ends, one slice gives it to you.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+