On Sun, 13 May 2007, LianYang < yanglian%40gmail.com">yanglian
gmail.com> wrote:
>
> thanks!
> $ ocamlc -c livenessanalysis.ml
> File "livenessanalysis.ml", line 26, characters 32-46:
> This expression has type unit but is here used with type string
Next time, show up the work you did to understand the problem! Also,
_attach_ the files, your livenessanalysis.ml below does not have 26
lines!
> let pf = Printf.printf
> let spf = Printf.sprintf
I do not recommend this. Open the Printf module and use printf and
sprintf instead.
> let join_map f l = String.concat "," (List.map f l)
> let pr_import x = pf "import b
^
You need to close the string.
Emacs with the tuareg mode will
avoid you making such silly mistakes.
> let emit exl =
> let rec stm = function
> T.LABEL l -> spf "%s:" (S.name l)
Where is the definition of the variant ?
> | T.CONT(l,ls) e -> spf "continuation %s(%s):"
> r) (S.name l) (join_map S.name ls)
^
Some function is missing here.
> | T.JUMP e -> spf "jmp %s;" (valexp e)
> | T.CJUMP(ex, l1, l2) -> spf "if(%s) {jmp %s;} else {jmp %s;}"
> (boolexp ex) (S.name l1) (S.name l2)
> | T.MOVE(e1, e2) -> mkEdge g n1 n2
About your subject "how to change type unit to string"
You CAN'T. This indicates an error of yours. The error means that
the compiler expects a string (because, say, other cases return a
string) but you gave an expression evaluating to () of type unit.
Cheers,
ChriS
.