Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/ml-burg/load
ViewVC logotype

View of /sml/trunk/src/ml-burg/load

Parent Directory Parent Directory | Revision Log Revision Log


Revision 250 - (download) (annotate)
Sat Apr 17 18:57:03 1999 UTC (20 years, 5 months ago) by monnier
File size: 2036 byte(s)
This commit was generated by cvs2svn to compensate for changes in r249,
which included commits to RCS files with non-trunk default branches.
(*
 * Load the files that make up mlburg, and prepare for use in
 * an interactive session.
 * You may need to change the path to the SML/NJ Library.
 *
 * To export an executable, *in an sml-noshare* :
 *      exportFn ("mlburg", Burg.prog);
 *)

let
  val smlnjLibDir = "../smlnj-lib/"
in

  app use [
	"errormsg.sml",
	"burg-ast.sml",
	"mlyacc-base.sml",
    	"burg-gram.sig",
	"burg-lex.sml",
    	"burg-gram.sml",
	"parse.sml",
	smlnjLibDir ^ "hash-key-sig.sml",
	smlnjLibDir ^ "hash-table-sig.sml",
	smlnjLibDir ^ "hash-table.sml",
	smlnjLibDir ^ "hash-string.sml",
	"burg.sml"
	]
end;

structure Burg = struct
  fun prog (argv, _) =
    let
      fun help () = output (std_err, "usage: mlburg [<filename>.burg]\n")
    in
      case argv of
	[] => output (std_err, "?? argv is []\n")
      | [_] => BurgEmit.emit (std_in, (fn () => std_out))
      | (_::"-h"::_) => help ()
      | (_::"-help"::_) => help ()
      | (_::files) => let
(**
	  fun findfile file = let
		val {dir, name, ext} = OS.Path.splitPath file
		in
		  case ext
		   of (OS.Path.EXT("brg" | "burg")) =>
			OS.Path.makePath{dir=dir, name=name, ext="sml"}
		    | _ => file ^ ".sml"
		  (* end case *)
		end
**)
	    fun findname file =
	      let
		val lenfile = String.length file
	      in
		(if ((lenfile>4) andalso (substring (file, lenfile-4, 4)=".brg"))
		   then substring (file, 0, lenfile-4)
		else if ((lenfile>5) andalso (substring (file, lenfile-5, 5)=".burg"))
		   then substring (file, 0, lenfile-5)
		else file)
		 ^".sml"
	      end
	    val names = map (fn n => (n,findname n)) files
	    fun emit (inname, outname) =
	      (let
		val s_in = open_in inname
	       in
		 BurgEmit.emit (s_in, (fn () => (open_out outname)))
	       end) 
		 handle (err as (Io s)) => (output (std_err, s^"\n"); raise err)
          in
	    app emit names
	  end
    end
  (*
   * This is the function to call in an interactive session.
   * Takes a filename (something.burg) as argument, and produces something.sml
   *)
  fun doit s = prog (["",s],())

end


root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0