diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2006-02-09 14:55:48 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2006-02-09 14:55:48 +0000 |
commit | 2ae43be7b9d4118335c9d2cef6e098f9b9f807fe (patch) | |
tree | bbb5e49ccbf7e3614966571acc317f8d318fecad /caml/Main2.ml | |
download | compcert-2ae43be7b9d4118335c9d2cef6e098f9b9f807fe.tar.gz compcert-2ae43be7b9d4118335c9d2cef6e098f9b9f807fe.zip |
Initial import of compcert
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'caml/Main2.ml')
-rw-r--r-- | caml/Main2.ml | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/caml/Main2.ml b/caml/Main2.ml new file mode 100644 index 00000000..b7014193 --- /dev/null +++ b/caml/Main2.ml @@ -0,0 +1,34 @@ +open Printf +open Datatypes + +let process_cminor_file sourcename = + let targetname = Filename.chop_suffix sourcename ".cm" ^ ".s" in + let ic = open_in sourcename in + let lb = Lexing.from_channel ic in + try + match Main.transf_cminor_program (CMparser.prog CMlexer.token lb) with + | None -> + eprintf "Compiler failure\n"; + exit 2 + | Some p -> + let oc = open_out targetname in + PrintPPC.print_program oc p; + close_out oc + with Parsing.Parse_error -> + eprintf "File %s, character %d: Syntax error\n" + sourcename (Lexing.lexeme_start lb); + exit 2 + | CMlexer.Error msg -> + eprintf "File %s, character %d: %s\n" + sourcename (Lexing.lexeme_start lb) msg; + exit 2 + +let process_file filename = + if Filename.check_suffix filename ".cm" then + process_cminor_file filename + else + raise (Arg.Bad ("unknown file type " ^ filename)) + +let _ = + Arg.parse [] process_file + "Usage: ccomp <options> <files>\nOptions are:" |