Neil Cerutti wrote:
> On 2007-01-10, Steven Bethard <[EMAIL PROTECTED]> wrote:
> > Neil Cerutti wrote:
> >> For use in a hand-coded parser I wrote the following simple
> >> iterator with look-ahead.
> >
> > There's a recipe for this:
> >
> >http://aspn.activestate.com/ASPN/Cookbook/Python/Rec
On 2007-01-10, Steven Bethard <[EMAIL PROTECTED]> wrote:
> Neil Cerutti wrote:
>> For use in a hand-coded parser I wrote the following simple
>> iterator with look-ahead.
>
> There's a recipe for this:
>
>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304373
>
> Note that the recipe ef
Neil Cerutti wrote:
> For use in a hand-coded parser I wrote the following simple
> iterator with look-ahead.
There's a recipe for this:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/304373
Note that the recipe efficiently supports an arbitrary look-ahead, not
just a single item.
Neil Cerutti wrote:
> For use in a hand-coded parser I wrote the following simple
> iterator with look-ahead. I haven't thought too deeply about what
> peek ought to return when the iterator is exhausted. Suggestions
> are respectfully requested. As it is, you can't be sure what a
> peek() => None
On 2007-01-10, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
> if you're doing simple parsing on an iterable, it's easier and
> more efficient to pass around the current token and the
> iterator's next method:
>
> http://online.effbot.org/2005_11_01_archive.htm#simple-parser-1
Thank you. Much better.
Neil Cerutti wrote:
> For use in a hand-coded parser I wrote the following simple
> iterator with look-ahead. I haven't thought too deeply about what
> peek ought to return when the iterator is exhausted. Suggestions
> are respectfully requested. As it is, you can't be sure what a
> peek() => None
For use in a hand-coded parser I wrote the following simple
iterator with look-ahead. I haven't thought too deeply about what
peek ought to return when the iterator is exhausted. Suggestions
are respectfully requested. As it is, you can't be sure what a
peek() => None signifies until the next itera