[mercury-users] Conditional compilation
Holger Krug
hkrug at rationalizer.com
Tue Feb 5 20:28:27 AEDT 2002
On Tue, Feb 05, 2002 at 06:21:11PM +1100, Michael Day wrote:
> True, but it would still require actually compiling the code that doesn't
> get called, which may not be possible on a particular platform if
> libraries/header files are not installed.
If used `cpp' in similar cases.
Here is a hacky perl-script which runs `cpp' on the mercury sources
and rewrites the line number information provided by `cpp' into the
format the Mercury parser requires.
#!/usr/bin/perl
# Usage: cpp4merc yourfile.m.in yourfile.m
#
# If you use emacs, add the following line to ~/.emacs:
# (setq auto-mode-alist (append '(("\\.m.in$" . mercury-mode))
# auto-mode-alist))
open( CPP , "cpp $ARGV[0]|" ) || die "Cannot call cpp on input file $ARGV[0]";
open( MERCURY , ">$ARGV[1]" ) || die "Cannot open output file $ARGV[1]";;
print MERCURY ":- pragma source_file(\"$ARGV[0]\").\n";
while ( <CPP> ) {
if ( /^\#\s*([0-9]*)/ ) { print MERCURY "#$1\n" ; } else {print MERCURY;}
}
--
Holger Krug
hkrug at rationalizer.com
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list