caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* OCamlduce + camlp4
@ 2007-12-24 13:55 Arnaud Spiwack
  2007-12-24 16:03 ` [Caml-list] " Alain Frisch
  0 siblings, 1 reply; 3+ messages in thread
From: Arnaud Spiwack @ 2007-12-24 13:55 UTC (permalink / raw)
  To: caml-list

Good day,

I was playing around with OCamlduce and camlp4. (for those who are 
interested, I'm trying to write ocsigen+eliom website modules using 
OCamlduce (for xhtml generation) and pa_monad (to simplify my code with 
respect to monadic threads which are central in ocsigen)).

There I discovered that I couldn't find a camlp4 syntax file for 
OCamlduce (to be able to extend OCamlduce's syntax). In my case, I'd 
like an equivalent to camlp4orf (original syntax, but revised-syntax 
quotations) that handles OCamlduce syntax (though, original-syntax 
quotation would require little to change, thus would be all right).

Does anybody know whether it already exists ? (maybe Alain or Nicolas ;) ).

If it does not, I shall consider making one myself, but I will have to 
know better of the insides of OCamlduce.



Regards

Arnaud Spiwack


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

* Re: [Caml-list] OCamlduce + camlp4
  2007-12-24 13:55 OCamlduce + camlp4 Arnaud Spiwack
@ 2007-12-24 16:03 ` Alain Frisch
  2007-12-24 19:36   ` Nicolas Pouillard
  0 siblings, 1 reply; 3+ messages in thread
From: Alain Frisch @ 2007-12-24 16:03 UTC (permalink / raw)
  To: Arnaud Spiwack, Caml mailing list

Arnaud Spiwack wrote:
> There I discovered that I couldn't find a camlp4 syntax file for 
> OCamlduce (to be able to extend OCamlduce's syntax). In my case, I'd 
> like an equivalent to camlp4orf (original syntax, but revised-syntax 
> quotations) that handles OCamlduce syntax (though, original-syntax 
> quotation would require little to change, thus would be all right).
> 
> Does anybody know whether it already exists ? (maybe Alain or Nicolas ;) ).
> 
> If it does not, I shall consider making one myself, but I will have to 
> know better of the insides of OCamlduce.

I'm not aware of a Camlp4 parser for OCamlduce (which probably means 
that such a thing does not exist). It should not be difficult (only 
quite boring) to write one. Of course, before writing the grammar, 
you'll have to extend Camlp4's OCaml syntax tree with new constructions 
and its translation to the real OCaml AST (Parsetree).

The OCamlDuce parser uses different lexers for the OCaml and CDuce 
parts. This is done by switching lexing mode on a few tokens ( {{, {:, 
:}, }}). It is possible to reproduce that with Camlp4 (you can plug an 
arbitrary lexer).

Let me know if you need more assistance on the OCamlDuce side...

Good luck!


-- Alain


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

* Re: [Caml-list] OCamlduce + camlp4
  2007-12-24 16:03 ` [Caml-list] " Alain Frisch
@ 2007-12-24 19:36   ` Nicolas Pouillard
  0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Pouillard @ 2007-12-24 19:36 UTC (permalink / raw)
  To: Alain Frisch; +Cc: Arnaud Spiwack, caml-list

Excerpts from Alain Frisch's message of Mon Dec 24 17:03:33 +0100 2007:
> Arnaud Spiwack wrote:
> > There I discovered that I couldn't find a camlp4 syntax file for 
> > OCamlduce (to be able to extend OCamlduce's syntax). In my case, I'd 
> > like an equivalent to camlp4orf (original syntax, but revised-syntax 
> > quotations) that handles OCamlduce syntax (though, original-syntax 
> > quotation would require little to change, thus would be all right).
> > 
> > Does anybody know whether it already exists ? (maybe Alain or Nicolas ;) ).
> > 
> > If it does not, I shall consider making one myself, but I will have to 
> > know better of the insides of OCamlduce.
> 
> I'm not aware of a Camlp4 parser for OCamlduce (which probably means 
> that such a thing does not exist). It should not be difficult (only 
> quite boring) to write one. Of course, before writing the grammar, 
> you'll have to extend Camlp4's OCaml syntax tree with new constructions 
> and its translation to the real OCaml AST (Parsetree).

Another  way  would be to treat {{...}} as some kind of quotation, and then by
only  using  OCaml  pretty printer (instead of the parsetree marshaller) where
these quotation are printed as is.

However  this  solution also have a cost, you will lose locations by not using
marshalled parsetrees, so I won't really recommend this direction.

> The OCamlDuce parser uses different lexers for the OCaml and CDuce 
> parts. This is done by switching lexing mode on a few tokens ( {{, {:, 
> :}, }}). It is possible to reproduce that with Camlp4 (you can plug an 
> arbitrary lexer).
> 
> Let me know if you need more assistance on the OCamlDuce side...
Let me know if you need more assistance on the Camlp4 side...

> Good luck!
You will need some.
-- 
Nicolas Pouillard aka Ertai


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

end of thread, other threads:[~2007-12-24 19:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-24 13:55 OCamlduce + camlp4 Arnaud Spiwack
2007-12-24 16:03 ` [Caml-list] " Alain Frisch
2007-12-24 19:36   ` Nicolas Pouillard

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).