Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Camlp4: syntax extension in source file
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alain Frisch <frisch@c...>
Subject: [Caml-list] Camlp4: syntax extension in source file

This thread about macro definition with Camlp4 reminds me of an idea I had
some time ago. The idea is to use the Toplevel lib to introduce Caml
syntax extension directly inside source file. Something like that:

  let x = ....

    expr: [ .... ];

The code between SYNTAX and END is parsed, compiled and executed by Camp4
during the preprocessing phase; it modifies the syntax used to parsed the
remaining of the rest of the file (including perhaps following SYNTAX ...
END statements). This allows a limited kind of reflexivity:  the source
file describes its own syntax. It also gives the possibility to perform
some computations at compile time (the "x" above).

I cannot remember why I didn't succeed to make it work (I think I had
some problems because of limitations in what the toplevel library

Daniel - and others - do you believe the above proposition makes sense ?

-- Alain

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: