[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Processing TEXT in MCL

> From: straz@cambridge.apple.com (Steve Strassmann)
> At 11:52 AM 7/31/94 -0700, David Evan Jones wrote:
>  >2.  How to automatically eliminate commas?
> Sounds like you need to write a "reader", which is a function that 
> opens and reads your file for you. There's a whole lot of ways to
> do this, but a cheapo way might be to loop inside the 
> with-open-file body (above), alternating calls to READ (to read 
> a value) and READ-CHAR (to read and ignore the comma after each
> value).
>  >3.  As far as I can tell, MCL is completely case-insensitive.  Is 
>  >there any way around this??? Is there a way for MCL to
>  >distinguish between upper and lower case in this text-file???
> You need to set the readtable-case of the readtable to :PRESERVE,
> or else read the input as strings, not symbols. Check out page 549
> in Common Lisp the Language, 2nd edition.
> Notice the code example on that page calls copy-readtable and uses
> a copy within a let. You should do that too - you really want to avoid
> messing with the top-level readtable that MCL uses. By making a copy,
> it'll be in effect strictly while you're reading in your data files.
> (see also around p 562)
> More ambitious hackers can read that whole section and get into hacking
> the entire reader mechanism.

Think carefully before taking this approach.  The Common Lisp reader
is not intended to be a general purpose parser.  For simple parsing it
is better to read your input as strings (using readline) and implement
your own parser with the features and capabilities that you need.  For
more complicated input there are several parsers listed in the lisp

Unless your input has lisp-like structure and you wish to preserve
that structure and use it in your program I would urge you to avoid
using the lisp reader.

Kevin Gallagher
Blackboard Technology Group, Inc.