Version française
Home     About     Download     Resources     Contact us    
Browse thread
camlp4 char stream
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Olivier Andrieu <andrieu@i...>
Subject: Re: [Caml-list] camlp4 char stream
 Christophe Raffalli [Monday 12 September 2005] :
 > 
 > OK, I found it (quote from your tutorial):
 > 
 > let operator_rparen =
 >    Grammar.Entry.of_parser gram "operator_rparen"
 >      (fun strm ->
 >         match Stream.npeek 2 strm with
 > 	 | [("", s); ("", ")")] when is_operator s ->
 > 	     begin
 > 	       Stream.junk strm;
 > 	       Stream.junk strm;
 > 	       s
 > 	     end
 > 	 | _ -> raise Stream.Failure)
 > 
 > OK, I read your tutorial, but did not get the point ... thks
 > 
 > and what is the first member of the tuple ?
 > Why is the second member a string and not a char ?

That's just how the camlp4 lexer works, cf. :
  http://caml.inria.fr/pub/docs/manual-camlp4/manual005.html#toc13
  http://caml.inria.fr/pub/docs/manual-camlp4/lib/Plexer.html

If I understand, you'd want to switch to a different lexer (and
parser) at some point. As Martin said, quotation expanders let you
basically do that. But IIRC camlp4 (the program) only expands
quotations in expression or pattern levels, not at the structure item
level so that won't work for you. But the ocpp program (installed with
camlp4) expands quotation in any file (only quotations returning
string of course).

-- 
   Olivier