Ruby: Remove instances of a method

Here’s an “old school” style jig. I first attempted this in Haskell, but I needed Perl-compatible regular expressions (Posix can’t handle the negative lookahead needed for correctly identifying C-style comments), and installing the PCRE library for Haskell on Windows is painful, though I’ll get around to it one of these days.

 
require ‘find’
 
Find.find "Components\\CommComponents" do |p|
[...]

September 3, 2009 • Tags: , , • Posted in: Jigs • Comments Closed

Haskell: Filter C++ Classes

I’ve needed a jig to separate a C++ class’s declaration and implementation for quite some time. Compile with “ghc -O2 –make classfilt.hs” and invoke with “classfilt –impl” or “classfilt –decl”, piping in the class source with inline methods. It certainly doesn’t handle all the corners of the C++ language, but it does most of [...]

August 18, 2009 • Tags: , • Posted in: Jigs • Comments Closed

Erlang: Remove #include directives from all cpp files

I’m certain this can be done better and with fewer lines of code, but it’s my first Erlang jig.

August 3, 2009 • Tags: , • Posted in: Jigs • Comments Closed

Scheme: Translate static data from C++ to XML

The C++ was extracted and munged with vim to make nice Scheme syntax elements before running this script.

(with-input-from-file "das.cpp"
(lambda ()
(do ((field-type (read) (read))
(field-length (read) (read))
(field-description (read) (read))
(bit-number (read) (read)))
((eof-object? field-type) #f)
[...]

June 23, 2009 • Tags: , , , • Posted in: Jigs • Comments Closed

Scheme: Save preprocessor output for all compiled files

This is a wrapper for the MSVC compiler (cl.exe) to generate a .i file as well as a .obj. Compiled with Bigloo.

(module cl-wrap
(main main))
 
(define (quote-args args)
(let loop ((args args)
(result ""))
(if (null? args)
result
[...]

June 7, 2009 • Tags: , , , , • Posted in: Jigs • Comments Closed