Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] web/email now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as OCaml by komar ( 15 years ago )
file module.ml:
let func x = print_endline x

  file pa.ml:
open Camlp4.PreCast
open Module
module Id = struct
  let name = "pa"
  let version = "0.01"
end
module Make (Syntax : Camlp4.Sig.Camlp4Syntax) = struct
  include Syntax
  EXTEND Gram
    GLOBAL: expr;
    expr: [ [ "Hello" -> Module.func "Hello world!"; <:expr< >>  ] ];
  END
end
module M = Camlp4.Register.OCamlSyntaxExtension(Id)(Make)

  file test.ml:
open Module
Hello

  building:
$ ocamlc -c module.ml
$ ocamlc -c -pp "camlp4of" -I /usr/lib/ocaml/3.11.0/camlp4 module.cmo pa.ml
$ ocamlc -c -pp "camlp4of pa.cmo" -I /usr/lib/ocaml/3.11.0/camlp4 module.cmo test.ml
Camlp4: Uncaught exception: DynLoader.Error ("./pa.cmo", "error while linking ./pa.cmo.
Reference to undefined global `Module'")

File "test.ml", line 1, characters 0-1:
Error: Preprocessor error

 

Revise this Paste

Your Name: Code Language: