Previous week Up Next week

Hello

Here is the latest Caml Weekly News, for the week of March 13 to 20, 2007.

  1. Style and organization of code
  2. OCaml Project in Google Summer of Code
  3. Imbedding a DSL into Ocaml: Camlp4
  4. Announcing OMake 0.9.8.1
  5. ocamlyacc, menhir, dypgen, camp4, elkhound
  6. Examples of parsing XML

Style and organization of code

Archive: http://groups.google.com/group/fa.caml/browse_frm/thread/21111d096cc38ea2/a4b6803d52ed2a20#a4b6803d52ed2a20

Ian asked, Gabriel Kerneis and Maxence Guesdon answered:
> > I'm looking for a guidebook or just some rules of thumb on how to organize 
> > my OCaml code. 
> 
> If you can read french : 
> http://caml.inria.fr/pub/old_caml_site/FAQ/pgl-fra.html 

This page and its english version were ported to the new site some 
months ago: 
http://caml.inria.fr/resources/doc/guides/guidelines.fr.html 
http://caml.inria.fr/resources/doc/guides/guidelines.en.html 
			

OCaml Project in Google Summer of Code

Archive: http://groups.google.com/group/fa.caml/browse_frm/thread/13b04f870253f02d/7f45ca175b7eed9b#7f45ca175b7eed9b

Yoriyuki Yamagata announced:
The FreeSoftware Initiative Japan(http://www.fsij.org/) is looking for 
participants of Google Summer of Code(http://code.google.com/soc). 
Proposed ideas (https://members.fsij.org/trac/soc2007/wiki/Ideas) 
include OCaml related projects. 
We also accept proposals not directly related to proposed ideas.  If 
your project is selected, you are paid 4500$ from Google. 
Please read carefully http://code.google.com/soc/tos.html and 
https://members.fsij.org/trac/soc2007/wiki/Ideas before submitting 
your proposal.  Feel free to ask me if you have a question. 

OCaml projects are 

*Improve OCaml internationalization 

There is no specific requirement. The idea includes 

    - Create a syntax extension which handle Unicode strings and 
locale-sensitive messages. Create a Unicode-based, locale-sensitive 
alternative of the standard library. 
    - Create a binding of ICU. Binding must not be bare-bone wrapping. 
It must be well integrated to OCaml and its programming customs. 

We accept other ideas as well. 

* Create Ajax development tool for OCaml 

Enable seamless Web development by generating JavaScript from OCaml 
and integrating it to Web framework. 

* Improve Eclipse plugin of OCaml 

There is no specific requirement. Please propose suitable improvements. 

Also we have a project about automatic source code verifiers. 

*Automatic program verifier 

Develop an automatic program verifier with the following features. 

    - Accept any programs in popular programing languages such as 
C/Java/Ruby and so on. 
    - Produce correct answers for programs in a practical subset of 
the language. 
    - Produce approximate answers for all programs in the language. 
    - Performance is not a goal. It suffices to demonstrate its 
capability to small code fragments. However, it must have modular 
design to future improvement.
			

Imbedding a DSL into Ocaml: Camlp4

Archive: http://groups.google.com/group/ocaml-developer/browse_frm/thread/532cfd6cc675e98b

Hugo Ferreira asked and Francisco Valverde answered:
> I have the need to use some logical programming functionality within my 
> application. I would like to embed this into my Ocaml code as a domain 
> specific language. I am contemplating the use of Camlp4 for this. M 

I recall reading an impressive presentation on how to do this (at least 
partially) in OCaml. Hold on... Yes, the wikipedia has the missing link! ;) 
http://www.venge.net/graydon/talks/mkc/html/mgp00002.html
			

Announcing OMake 0.9.8.1

Archive: http://groups.google.com/group/fa.caml/browse_frm/thread/f4460a94f244e6ed/9ed1ec7694e27cf6#9ed1ec7694e27cf6

Aleksey Nogin announced:
We are proud to announce the latest release of the OMake Build System - 
OMake version 0.9.8.1. 
OMake is a build system designed for scalability and portability. It 
uses a syntax similar to make utilities you may have used, but it 
features many additional enhancements, including the following. 

   - Support for projects spanning several directories or directory 
     hierarchies. 

   - Fast, reliable, automated, scriptable dependency analysis using MD5 
     digests, with full support for incremental builds. 

   - Fully scriptable, includes a library that providing support for 
     standard tasks in C, C++, OCaml, and LaTeX projects, or a mixture 
     thereof. 

     Often, a configuration file is as simple as a single line 

     .DEFAULT: $(OCamlProgram prog, foo bar baz) 

     which states that the program "prog" is built from the files foo.ml, 
     bar.ml, and baz.ml. This one line will also invoke the default 
     standard library scripts for discovering implicit dependencies in 
     OCaml files. 

   - Full native support for rules that build several files at once. 

   - Portability: omake provides a uniform interface on Linux/Unix 
     (including 64-bit architectures), Win32, Cygwin, Mac OS X, and other 
     platforms that are supported by OCaml. 

   - Built-in functions that provide the most common features of programs 
     like grep, sed, find, and awk. These are especially useful on Win32. 

   - Active filesystem monitoring, where the build automatically restarts 
     whenever you modify a source file. This can be very useful during 
     the edit/compile cycle. 

   - A built-in command-interpreter osh that can be used interactively. 

OMake preserves the style of syntax and rule definitions used in 
Makefiles, making it easy to port your project to OMake. There is no 
need to code in Perl (cons), or Python (scons). However, there are a few 
things to keep in mind: 

  1. Indentation is significant, but tabs are not required. 
  2. The OMake language is functional: functions are first-class and 
     there are no side-effects apart from I/O. 
  3. Scoping is dynamic. 

OMake is licensed under a mixture of the GNU GPL license (OMake engine 
itself) and the MIT-like license (default configuration files). 

Additional information and extensive documentation can be found on OMake 
Home Page at http://omake.metaprl.org/ 

OMake version 0.9.8.1 is a minor feature enhancements and bugfixes 
release. The changes in this version include: 

  - Added a large number of new built-in and standard library functions 
  - Extented the autocomfiguration section of the standard library 
  - A number of improvements in the interactive osh shell. 
  - A number of improvements in the library of standard build recipes 
  - Documentation improvements. 
  - A number of other improvements and bugfixes. 

For a more verbose change log, please visit 
http://omake.metaprl.org/changelog.html#0.9.8.1 . 

Source and binary packages of OMake 0.9.8.1 may be downloaded from 
http://omake.metaprl.org/download.html . In addition, OMake may be 
obtained via the GODI packaging system. 

To try it out, run the command "omake --install" in a project directory, 
and modify the generated OMakefile. 

OMake 0.9.8.1 is still an alpha release.  While we have made an effort 
to ensure that it is bug-free, it is possible some functions may not 
behave as you would expect.  Please report any comments and/or bugs to 
the mailing list omake@metaprl.org and/or at http://bugzilla.metaprl.org/
			
Nathaniel Gray added:
FYI, the OS X PPC package is now available.
			

ocamlyacc, menhir, dypgen, camp4, elkhound

Archive: http://groups.google.com/group/fa.caml/browse_frm/thread/02477e8de62fb685/49c2373ee8189931#49c2373ee8189931

Christophe Raffalli asked:
The programs listed in the subject of this mail are parser generators 
for OCaml ... 
There may be others, and there is also the possibility to write parsers 
by hand using stream pattern matching, parser combinators, etc ... 
(the later technics are not covered here) 

It would be nice to have a small comparison table to help people making 
a decision ? Being not neutral 
(dypgen was developped by a student at ENS lyon under my direction) I 
think I should not do it myself ... 

But I gave it a try. Here is a first draft (This table is not correct 
yet and should not be used to make a decision ;-) 

http://www.lama.univ-savoie.fr/~raffalli/ocaml-parsing.html 

The html produced by ooffice is poor and the calculator example is not 
well presented due to an ooffice bug (I think). 

Questions 

- Can you help me complete the table (missing lines, columns,   
inaccurate or missing information) ? 
- Can you provide the best possible calculator example for the other 
parser as a text file ? 
- Can you provide a really difficult but short grammar to make a better 
comparison ? 
- Other Idea welcome 
- If someone neutral wants to volonteer to host this comparison table, I 
will be very please to send him the source of the table.
			
Aleksey Nogin answered:
I am not an expert in camlp4, but I probably know enough to be able to 
fill in a few blanks in the last column of your table. My answers are 
based on "old" 3.09 camlp4 and might be different for the new 3.10 one. 

Handled grammar: LL(1) 

Reentrant: Yes, but with caveats(*1) 

Extensible (an action can change the grammar): Yes(*2) 

Parametrized non terminal: No (???, *3) 

Splitting the definition of a non terminal: Yes 

Grammars parametrized by Ocaml modules: ??? (Yes? - *4) 

Partial action: No 

Ambiguous grammars: Yes (???, *5) 

Exception to reject a rule: No (???) 

Priority: Using levels (= a partial order as a relation) + associativity 
direction 

Debugging grammars: hard 

--- 

(*1) In 3.09, reentrant parsing works, except the error messages might 
end up pointing to the wrong place in the source stream (supposed to be 
fixed in 3.10, AFAIK). However, there is no good way of passing a state 
to the grammar actions. As a result, one often has to resort to using a 
global ref to hold the state, which, obviously, kills the ability to be 
reentrant. 

(*2) For example, see the pa_macro where the action for the DEFINE and 
UNDEF expressions change the grammar accordingly. 

(*3) As far as I understand, only tokens 
can be parameterized, although that might have changed in 3.10. 

(*4) I am not sure which capability exactly is meant here. In Camlp4, 
the grammar definitions/extensions can be done inside a body of a 
functor. The actual grammar is created when the functor is applied. 

(*5) Not sure what is meant here. In camlp4, unfortunately, there is no 
way to test the grammar for ambiguities - it accepts an ambiguous 
grammar without any warnings.
			

Examples of parsing XML

Archive: http://groups.google.com/group/ocaml-developer/browse_frm/thread/e4882cb3243d3114

Gordon asked and Daniel answered:
> Does anyone have any moderate level examples of parsing XML using a 
> SAX style parser to build data structures?  I'm trying to use Expat to 
> do some XML parsing and I just seem to be having a mental block as to 
> how to build up a data structure in this style.

The examples on this page [1] may help. They show how to build the 
document tree using a SAX style parser. 
Daniel 

[1] http://xmlm.googlecode.com/svn/trunk/distrib/xmlm-0.9.0/doc/Xmlm.html#ex 
			

Using folding to read the cwn in vim 6+

Here is a quick trick to help you read this CWN if you are viewing it using vim (version 6 or greater).

:set foldmethod=expr
:set foldexpr=getline(v:lnum)=~'^=\\{78}$'?'<1':1
zM

If you know of a better way, please let me know.


Old cwn

If you happen to miss a CWN, you can send me a message and I'll mail it to you, or go take a look at the archive or the RSS feed of the archives.

If you also wish to receive it every week by mail, you may subscribe online.


Alan Schmitt