caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Strange OCaml bug
@ 2006-01-05 12:41 Tom Wilkie
  2006-01-05 13:13 ` [Caml-list] " Jean-Christophe Filliatre
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Wilkie @ 2006-01-05 12:41 UTC (permalink / raw)
  To: caml-list; +Cc: Tom Wilkie

[-- Attachment #1: Type: text/plain, Size: 1923 bytes --]

Dear all

This is my first post, so I'm sorry of this is a bit unusual or not  
what this mailing list is for.   I've googled and search mailing list  
archive, but didn't find anything. I'm using OCaml (version 3.08.4)  
on my PowerBook, Mac OS 10.4.3, to develop my Dissertation, and have  
run into a big problem, which I can't find a solution to...

The project is a tool for language writers.  You give it a language  
defn in a made up meta language (test.ott), and it spits out yacc,  
lex, ocaml datatypes (based on sugar and the ocfg tool by Stephen  
Tse) and some code to calculate the binding of variables within  
expressions (similar to alphaCaml, but not).

The project is in its early stages, lots more work to do, but here is  
the problem at the mo:

When I add some code (which typechecks and compiles correctly) the  
tool generates empty files.  If I then comment out this code, the  
files are back again.  The code is in generate_alpha.ml, lines  
207-212, and this files has nothing to do with the generated Yacc or  
Lex.  Very strange.  I've tried compiling it to byte code and native,  
to no avail.  The project is very modular, those files beginning with  
yacc_* generate yacc, lex_* generate lex and so on...  I even made it  
spit the code generated out to the terminal, and its there!  It just  
doesn't write to the file!  Is there a problem on OS X with writing  
files?

If any one has any ideas, please reply! this is a show stopper for  
me.  I've attached my project, to build it with a quick test to  
highlight the problem, untar and do a:

make test

And it compiles and works fine.  Uncomment the lines in  
generate_alpha.ml, type

make test

and most of the files the tool generates are empty!! (look in test/)

If you put VERSION=NATIVE on the make cmd line then it will compile  
with ocamlopt.  Same results on my computer.

Any help would be much appreciated!

Cheers

Tom


[-- Attachment #2: my.tar.gz --]
[-- Type: application/x-gzip, Size: 28677 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Strange OCaml bug
  2006-01-05 12:41 Strange OCaml bug Tom Wilkie
@ 2006-01-05 13:13 ` Jean-Christophe Filliatre
  0 siblings, 0 replies; 2+ messages in thread
From: Jean-Christophe Filliatre @ 2006-01-05 13:13 UTC (permalink / raw)
  To: Tom Wilkie; +Cc: caml-list


Hello,

I gave it a quick look and  it seems that your problem comes from some
lack  of flushing  when writing  strings  into files.  I rewrite  your
File_utils.write function into

======================================================================
let write: file -> string -> unit = 
  let f s text =  
    let c = open_out (Filename.concat !name s) in
    output_string c text;
    close_out c
  in
  ...
======================================================================

and it now works fine apparently.

Hope this helps,
-- 
Jean-Christophe Filliâtre (http://www.lri.fr/~filliatr)


Tom Wilkie writes:
 > Dear all
 > 
 > This is my first post, so I'm sorry of this is a bit unusual or not  
 > what this mailing list is for.   I've googled and search mailing list  
 > archive, but didn't find anything. I'm using OCaml (version 3.08.4)  
 > on my PowerBook, Mac OS 10.4.3, to develop my Dissertation, and have  
 > run into a big problem, which I can't find a solution to...
 > 
 > The project is a tool for language writers.  You give it a language  
 > defn in a made up meta language (test.ott), and it spits out yacc,  
 > lex, ocaml datatypes (based on sugar and the ocfg tool by Stephen  
 > Tse) and some code to calculate the binding of variables within  
 > expressions (similar to alphaCaml, but not).
 > 
 > The project is in its early stages, lots more work to do, but here is  
 > the problem at the mo:
 > 
 > When I add some code (which typechecks and compiles correctly) the  
 > tool generates empty files.  If I then comment out this code, the  
 > files are back again.  The code is in generate_alpha.ml, lines  
 > 207-212, and this files has nothing to do with the generated Yacc or  
 > Lex.  Very strange.  I've tried compiling it to byte code and native,  
 > to no avail.  The project is very modular, those files beginning with  
 > yacc_* generate yacc, lex_* generate lex and so on...  I even made it  
 > spit the code generated out to the terminal, and its there!  It just  
 > doesn't write to the file!  Is there a problem on OS X with writing  
 > files?
 > 
 > If any one has any ideas, please reply! this is a show stopper for  
 > me.  I've attached my project, to build it with a quick test to  
 > highlight the problem, untar and do a:
 > 
 > make test
 > 
 > And it compiles and works fine.  Uncomment the lines in  
 > generate_alpha.ml, type
 > 
 > make test
 > 
 > and most of the files the tool generates are empty!! (look in test/)
 > 
 > If you put VERSION=NATIVE on the make cmd line then it will compile  
 > with ocamlopt.  Same results on my computer.
 > 
 > Any help would be much appreciated!
 > 
 > Cheers
 > 
 > Tom
 > 
 > _______________________________________________
 > Caml-list mailing list. Subscription management:
 > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
 > Archives: http://caml.inria.fr
 > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
 > Bug reports: http://caml.inria.fr/bin/caml-bugs



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-05 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-05 12:41 Strange OCaml bug Tom Wilkie
2006-01-05 13:13 ` [Caml-list] " Jean-Christophe Filliatre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).