caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Is it possible to extend OCaml lexer rules via Camlp4?
@ 2011-11-02 20:34 Jun Furuse
  2011-11-02 22:52 ` Gabriel Scherer
  0 siblings, 1 reply; 6+ messages in thread
From: Jun Furuse @ 2011-11-02 20:34 UTC (permalink / raw)
  To: caml-list

Hi,

Is it possible for Camlp4 to implement an OCaml syntax extension (i.e.
pa_*) which modifies the lexer of OCaml syntax?

I have tried to override whole the syntax as follows, but it seems
that it changes nothing...:

-----------------------------------------------------------
open Camlp4

module Id : Sig.Id = struct
  let name = "pa_extlex"
  let version = "1.0"
end

module XLexer = Xlexer.Make(PreCast.Token)        (* XLexer
reimplements OCaml lexer with some extra rules *)
module XGram = PreCast.MakeGram(XLexer)

module Make (Syntax : Sig.Camlp4Syntax) = struct
  let _ = prerr_endline "Creating OCaml syntax with lexer extension"
  module M1 = OCamlInitSyntax.Make(PreCast.Ast)(XGram)(PreCast.Quotation)
  module M2 = Camlp4OCamlRevisedParser.Make(M1)
  module M3 = Camlp4OCamlParser.Make(M2)
  include M3
end

let module M = Register.OCamlSyntaxExtension(Id)(Make) in ()
-----------------------------------

Jun

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

end of thread, other threads:[~2011-11-06  0:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-02 20:34 [Caml-list] Is it possible to extend OCaml lexer rules via Camlp4? Jun Furuse
2011-11-02 22:52 ` Gabriel Scherer
2011-11-03  7:12   ` Jun Furuse
2011-11-03  9:16     ` Jérémie Dimino
2011-11-05 21:19       ` Nicolas Pouillard
2011-11-06  0:58         ` Jun Furuse

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