[chuck-users] upchuck: a chuck preprocessor

Scott Wheeler wheeler at kde.org
Thu Nov 29 02:41:22 EST 2007


Since I do a lot of OO-ish stuff in ChucK and tend to reuse my standard 
classes a lot, the lack of an import mechanism or preprocessor was 
getting on my nerves.  I hacked up a (not-entirely-so-) quick one last 
night in Perl.

The only preprocessor command supported at this point is "include".  The 
syntax is:

#include(Something.ck)

or, to make things prettier:

#include(Something)

It will automatically search the current working directory, check to see 
if appending a ".ck" helps, and then do the same for every directory in 
the colon separated $CHUCK_DIRS. 

Extra credit is that it:

- Checks to avoid double includes, recursive includes, etc.
- Automatically passes all non-file arguments on to ChucK
- Translates error messages back to the original files (rather than the 
temp file that ChucK actually executes; this was a pain since ChucK uses 
stderr for output and errors)

So, let's play with it a little.  I've attached a couple of small files 
to be put in ~/ChucK.  I've got upchuck in ~/bin, which is in my path.

Then from the shell:

export CHUCK_DIRS=~/ChucK
upchuck Quux

"Foo" : (string)
"Bar" : (string)
"Baz" : (string)

This won't work on Windows, but I suspect the only thing that needs to 
be reimplemented is the tempName subroutine (which you could just write 
in Perl in about 2 minutes -- I just don't know what the standard temp 
dir is on Windows).

-Scott
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: upchuck
Url: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20071129/c1ff8ce3/attachment-0005.bat 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Bar.ck
Url: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20071129/c1ff8ce3/attachment-0006.bat 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Quux.ck
Url: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20071129/c1ff8ce3/attachment-0007.bat 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Baz.ck
Url: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20071129/c1ff8ce3/attachment-0008.bat 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Foo.ck
Url: http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20071129/c1ff8ce3/attachment-0009.bat 


More information about the chuck-users mailing list