


## main.pkg
# Compiled by:
# src/app/burg/Ml-Burg.make6# $Log: main.pkg, v $
# Revision 1.4 2001/11/21 21:03:16 blume
# Release 110.37 -- see HISTORY
#
# Revision 1.3.4.1 2001/11/17 03:14:16 blume
# fixed uses of exception_message in executables
#
# Revision 1.3 2000/06/01 18:33:42 monnier
# bring revisions from the vendor branch to the trunk
#
# Revision 1.2 2000/03/07 03:59:09 blume
# build script now uses new mechanism for building standalone programs
#
# Revision 1.1.1.8.4.1 2000/02/20 14:44:33 blume
# make_compiler.deliver merged with make_compiler.make; runtime boot code made more flexible
#
# Revision 1.1.1.8 1999/04/17 18:56:04 monnier
# version 110.16
#
# Revision 1.1.1.1 1997/01/14 01:37:59 george
# Version 109.24
#
# Revision 1.1.1.2 1997/01/11 18:52:31 george
# ml-burg Version 109.24
#
# Revision 1.3 1996/02/26 16:55:12 jhr
# Moved spawn_to_disk/fork_to_disk to Lib7 package.
#
# Revision 1.2 1996/02/26 15:02:06 george
# print no longer overloaded.
# use of makestring has been removed and replaced with int::to_string ..
# use of IO replaced with file
#
# Revision 1.1.1.1 1996/01/31 16:01:25 george
# Version 109
package main {
fun main (command_name, argv)
=
{ fun help ()
=
{ file::write (file::stderr, "usage: mlburg [<filename>.burg]\n");
winix::process::failure;
};
case argv
[] => { burg_emit::emit (file::stdin, (fn () = file::stdout));
winix::process::success;
};
("-h" ! _) => help ();
("-help" ! _) => help ();
files
=>
{ fun findname file
=
{ my { base, ext }
=
winix::path::split_base_ext file;
case ext
(THE("brg" | "burg"))
=>
winix::path::join_base_ext { base, ext=>THE "sml"};
_ => file + ".sml";
esac;
};
names = map (fn n = (n, findname n)) files;
fun emit (inname, outname)
=
{ s_in = file::open_for_read inname;
burg_emit::emit (s_in, (fn () = (file::open_for_write outname)));
}
except
err = { file::write (
file::stderr,
exceptions::exception_message err + "\n"
);
raise exception err;
};
apply emit names;
winix::process::success;
};
esac;
};
# This is the function to call in an interactive session.
# Takes a filename (something.burg) as argument, and produces something.sml
fun do_it s
=
main ("", [s]);
};
## COPYRIGHT (c) 1994 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010,
## released under Gnu Public Licence version 3.


