Version française
Home     About     Download     Resources     Contact us    
Browse thread
Camlp4 lexers (>= 3.10)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Gabriel Kerneis <kerneis@e...>
Subject: Re: [Caml-list] Camlp4 lexers (>= 3.10)
On Fri, May 02, 2008 at 01:15:36PM -0700, O'Leary, John W wrote:
> Does anyone have an example that would show me how to connect my own
> lexer to a Camlp4 parser?

You can have a look at Ocsigen's xmlp4 module (allowing you to type
xhtml code in quotations and get an AST):

http://ocsigen.org/darcsweb/?r=ocsigen.current;a=tree;f=/xmlp4/newocaml

Especially the files xmllexer.mll (using ocamlex, based on lexer.mll
from ocaml source) and xhtmlparser.ml (written in revised syntax). 

The interresting parts are at the end of both files (look at functions
Xmllexer.from_string = Xhtmlparser.parse, Xhtmlparser.xml_exp).

Regards,
-- 
Gabriel Kerneis