From: e@flavors.com (Doug Currie, Flavors Technology, Inc.)
To: Judicael.Courant@lip.ens-lyon.fr (Judicael Courant)
Cc: Pierre.Weis@inria.fr
Subject: Re: Dead code removal / cross references
Date: Fri, 11 Nov 1994 14:18:28 -0500 [thread overview]
Message-ID: <9411111917.AA22284@uu3.psi.com> (raw)
>called/used ? which modules are used by this one ? is this #open
>really necessary ?) and detect and remove the useless #open and the
>dead code. Does such a tool exists ?
Here is a small piece of what you need...
(* usedmodu.ml *)
(* Copyright ) e, 1994. All rights reserved.
This code may be freely distributed as long as this notice remains.
*)
(* To read a file, and return the list of the modules used *)
let letter_p c =
let x = int_of_char c in
((x > 0x40) & (x < 0x5b)) or ((x > 0x60) & (x < 0x7b))
;;
let identchp c =
let x = int_of_char c in
((x > 0x40) & (x < 0x5b))
or ((x > 0x60) & (x < 0x7b))
or ((x > 0x2f) & (x < 0x3a))
;;
let sm ic =
let buf = create_string 1024 in
let mds = ref [] in
let addm i =
let m = (sub_string buf 0 i) in
if mem m !mds
then ()
else mds := (m :: !mds) in
let
rec s0 () = (* eat whitespace *)
while (*
match input_char ic with
` ` | `\n` | `\r` | `\t` -> true
| c -> set_nth_char buf 0 c; false
*)
let c = input_char ic in
if (letter_p c) or (c = `#`)
then begin set_nth_char buf 0 c; false end
else true
do () done;
s1 1
and s1 i = (* get token *)
match input_char ic with
(*
` ` | `\n` | `\r` | `\t` -> s5 i
| *)
`_` -> begin
match input_char ic with
`_` -> s2 i
| c -> let j = (succ i) in
set_nth_char buf i `_`;
set_nth_char buf j c;
s1 (succ j)
end
| c -> if identchp c
then begin set_nth_char buf i c; s1 (succ i) end
else s5 i
and s2 i = (* record module, eat non-whsp *)
addm i;
while match input_char ic with
` ` | `\n` | `\r` | `\t` -> false
| c -> true
do () done;
s0 ()
and s5 i = (* look for #open *)
if (i = 5) &
((nth_char buf 0) = `#`) &
((nth_char buf 1) = `o`) &
((nth_char buf 2) = `p`) &
((nth_char buf 3) = `e`) &
((nth_char buf 4) = `n`)
then
begin
while (input_char ic) != `"` do () done;
let rec f i =
let c = input_char ic in
if c = `"`
then addm i
else begin set_nth_char buf i c; f (succ i) end in
f 0;
s0 ()
end
else s0 ()
in
try
s0 ()
with End_of_file ->
rev !mds
;;
let modules_used_by_file filename =
let ic = open_in filename in
let res = sm ic in
close_in ic;
res
;;
(* ********************************************* *)
next reply other threads:[~1994-11-14 9:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-11-11 19:18 Doug Currie, Flavors Technology, Inc. [this message]
-- strict thread matches above, loose matches on Subject: below --
1994-11-10 8:11 Judicael Courant
1994-11-14 10:38 ` Xavier Leroy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9411111917.AA22284@uu3.psi.com \
--to=e@flavors.com \
--cc=Judicael.Courant@lip.ens-lyon.fr \
--cc=Pierre.Weis@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox