Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
question about camlp4 and lexer
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-08-18 (17:32)
From: Christophe Raffalli <raffalli@u...>
Subject: question about camlp4 and lexer


For a camlp4 extension, I want to add some delimiters:
  (^  ^)  [^ ^] {^ ^} [|^ ^|].

It does not break anything and it works quite well ... my problem is
that I find it a bit hard to compile the camlp4 extension.
Here is a part of my Makefile:

# compilation of the lexer
    $(CAMLC) -pp "camlp4r -loc _loc"  -I +camlp4 -c

# recompilation of (unmodified and directly copied from the
source of ocaml)
pa_o.cmo: mylexer.cmo
    $(CAMLC) -pp "camlp4r pa_extend.cmo q_MLast.cmo -loc _loc"  -I
+camlp4 -c

# my syntax extension
pa_bindlib.cmo: bindlib.cmi pa_o.cmo
    $(CAMLC) -pp "camlp4 ./mylexer.cmo ./pa_o.cmo pa_extend.cmo
q_MLast.cmo pr_dump.cmo -loc _loc"  -I +camlp4 -c

# linking of a camlp4 preprocessor
camlp4bo: pa_bindlib.cmo
    $(CAMLC) -linkall -I +camlp4 odyl.cma camlp4.cma ./mylexer.cmo
./pa_o.cmo pa_bindlib.cmo pr_dump.cmo odyl.cmo -o camlp4bo

I do not understand why I need to recompile and cannot use
pa_o.cmo in "ocaml/camlp4" (I tried but it uses the original lexer and
not mine) ...
This is a bit annoying and I am probably doing something wrong ...

Thanks in advance for you help,
Christophe Raffalli

By the way, I think the default lexer should consider (xxx xxx) [xxx
xxx] {xxx xxx} as delimiters whenever xxx is an infix keyword ... so
camlp4 user would have a big choice of delimiters ...