Prev: Disjoint sets
Next: ecl on cygwin
From: Bastien Dejean on 23 May 2010 05:38 Hi, I'm trying to use the pprint function as a code beautifier. Here's my first draft : #!/opt/local/bin/sbcl --script (let ((*print-case* :downcase)) (do ((c (read nil nil nil) (read nil nil nil))) ((null c)) (pprint c) (terpri))) Meant usage : cat foo.lisp | cltidy. Unfortunately, comments are ignored… Thanks.
From: D Herring on 23 May 2010 21:05 On 05/23/2010 05:38 AM, Bastien Dejean wrote: > I'm trying to use the pprint function as a code beautifier. > Here's my first draft : > > #!/opt/local/bin/sbcl --script > > (let ((*print-case* :downcase)) > (do ((c (read nil nil nil) (read nil nil nil))) > ((null c)) > (pprint c) > (terpri))) > > Meant usage : cat foo.lisp | cltidy. > Unfortunately, comments are ignored… Yes, that will happen. Unfortunately, the standard reader cannot return forms with annotations like comments. Something like `emacs --eval ...` might be a better approach. - Daniel
From: Captain Obvious on 24 May 2010 06:14 BD> I'm trying to use the pprint function as a code beautifier. BD> Here's my first draft : BD> #!/opt/local/bin/sbcl --script BD> (let ((*print-case* :downcase)) BD> (do ((c (read nil nil nil) (read nil nil nil))) BD> ((null c)) BD> (pprint c) BD> (terpri))) BD> Meant usage : cat foo.lisp | cltidy. BD> Unfortunately, comments are ignored… As well as reader macros, read time evaluation...
From: Zach Beane on 24 May 2010 06:31 D Herring <dherring(a)at.tentpost.dot.com> writes: > On 05/23/2010 05:38 AM, Bastien Dejean wrote: >> I'm trying to use the pprint function as a code beautifier. >> Here's my first draft : >> >> #!/opt/local/bin/sbcl --script >> >> (let ((*print-case* :downcase)) >> (do ((c (read nil nil nil) (read nil nil nil))) >> ((null c)) >> (pprint c) >> (terpri))) >> >> Meant usage : cat foo.lisp | cltidy. >> Unfortunately, comments are ignored… > > Yes, that will happen. Unfortunately, the standard reader cannot > return forms with annotations like comments. Comments aren't too big an issue, since you can just make a readtable that does something different with ; and #|. Package prefixes would be a bigger issue, since the behavior of : and :: in symbols can't be customized in a standard way. Zach
From: Pascal J. Bourguignon on 24 May 2010 13:14
Zach Beane <xach(a)xach.com> writes: > D Herring <dherring(a)at.tentpost.dot.com> writes: > >> On 05/23/2010 05:38 AM, Bastien Dejean wrote: >>> I'm trying to use the pprint function as a code beautifier. >>> Here's my first draft : >>> >>> #!/opt/local/bin/sbcl --script >>> >>> (let ((*print-case* :downcase)) >>> (do ((c (read nil nil nil) (read nil nil nil))) >>> ((null c)) >>> (pprint c) >>> (terpri))) >>> >>> Meant usage : cat foo.lisp | cltidy. >>> Unfortunately, comments are ignored… >> >> Yes, that will happen. Unfortunately, the standard reader cannot >> return forms with annotations like comments. > > Comments aren't too big an issue, since you can just make a readtable > that does something different with ; and #|. Package prefixes would be a > bigger issue, since the behavior of : and :: in symbols can't be > customized in a standard way. Funny, I don't remember having used anything out of pure standard Common Lisp to implement my reader, and with it, the behavior of : and :: in symbols can be perfectly well customized. http://git.informatimago.com/viewgit/?a=viewblob&p=public/lisp&h=d51b4dfa339e219ad5c0de1a6148697a760603f7&hb=5b22e7eab73f004ef00d478a119d5f4582174018&f=common-lisp/reader.lisp ;-) -- __Pascal Bourguignon__ http://www.informatimago.com/ |