[plt-scheme] v299.27 parser-tools -- how do unput() or yyless()?

From: Scott A Owens (sowens at cs.utah.edu)
Date: Wed Feb 16 16:07:49 EST 2005

The lexer does not provide its own stream abstraction, but instead works 
directly on input-ports.  An input-port has no method to do what you want 
directly.  However, the input-port-append function in the port.ss library 
does most of what you want (in combination with open-input-string), with two 
provisos.

The port returned by input-port-append will start counting locations from 0. 
If you are tracking locations, you'll have to remember an offset to add to 
the resulting locations.

Calling inport-port-append with a port created with input-port-append creates 
a chain of input ports that must be traversed on peeks/reads.  This might 
impact performance if you make the chain too long.  If you have always read 
down to the original input-port in the appended input-port, you could perform 
a subsequent append on the original input port and avoid the chain.

-Scott

On Wednesday 16 February 2005 01:29 pm, Anthony Wuersch wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Subject line says it all, but if not ...
>
> I'd like to vector to another lexer upon failure (which in my lexer means
> matching ".") but I don't see how to push back "." .
>
> 'port-next-location' doesn't respect 'file-position' changes, so resetting
> via file-position isn't good enough.
>
> Hopefully I don't have to reinstantiate the input port to read up to just
> before "." ?
>
> Is an escape continuation the Scheme-y way to go here?
>
> Toni
>
> -----------------------------------------
> This message and its attachments may contain  privileged and confidential
> information.  If you are not the intended recipient(s), you are prohibited
> from printing, forwarding, saving or copying this email.  If you have
> received this e-mail in error, please immediately notify the sender and
> delete this e-mail and its attachments from your computer.



Posted on the users mailing list.