[antlr-interest] Positioning input stream (was EOL sequence)

Terence Parr parrt at cs.usfca.edu
Wed Dec 17 09:22:24 PST 2003


Don't forget my mini postscript interpreter lab I had my students do 
last semester....link on my course page at USF (CS652).

Ter
On Wednesday, December 17, 2003, at 09:08  AM, Albert Huh wrote:

> i don't know too much about ps syntax, but you could simply make your 
> whitespace rule consume spaces as well as newlines in your lexer.  the 
> java example that comes with antlr does this.
>
> -----Original Message-----
> From: skapp at rochester.rr.com [mailto:skapp at rochester.rr.com]
> Sent: Wednesday, December 17, 2003 12:04 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] Positioning input stream (was EOL sequence)
>
>
> I have worked out enough details with the EOL sequences to
> understand where my PostScript parser is failing. PostScript parsers
> have to be able to handle the following four example sequences
> identically:
>
> currentfile read 3
> currentfile read<CR>3
> currentfile read<LF>3
> currentfile read<CR><LF>3
>
> where the "currentfile read" operator sequence instructs the
> PostScript interpreter to read one byte from the input stream.
>
> There is no issue with the first three examples. The input stream
> point just past the EOL byte once the "read" operator has been
> recognized. Then the read operator simply has to pull one byte from
> the input stream (a FileInputStream in this case).
>
> However, in the fourth case, the input stream points to the <LF>
> character when the "read" operator has been recognized. The
> PostScript spec states that "Any of the three forms of EOL ... is
> treated as a single white-space character."
>
> How do I handle this? What can or should I do in the lexer versus in
> the parser?
>
> Regards,
>
>    Steve
>
>
>
>
>
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
>  http://groups.yahoo.com/group/antlr-interest/
>
> To unsubscribe from this group, send an email to:
>  antlr-interest-unsubscribe at yahoogroups.com
>
> Your use of Yahoo! Groups is subject to:
>  http://docs.yahoo.com/info/terms/
>
>
>
>
>
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
>  http://groups.yahoo.com/group/antlr-interest/
>
> To unsubscribe from this group, send an email to:
>  antlr-interest-unsubscribe at yahoogroups.com
>
> Your use of Yahoo! Groups is subject to:
>  http://docs.yahoo.com/info/terms/
>
>
>
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com link sharing, pure-n-simple




 

Yahoo! Groups Links

To visit your group on the web, go to:
 http://groups.yahoo.com/group/antlr-interest/

To unsubscribe from this group, send an email to:
 antlr-interest-unsubscribe at yahoogroups.com

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




More information about the antlr-interest mailing list