Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
From: Christophe Raffalli <raffalli@u...>
Subject: question about camlp4 and lexer

Hello,

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
mylexer.cmo: mylexer.ml
    $(CAMLC) -pp "camlp4r -loc _loc"  -I +camlp4 -c mylexer.ml

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

# my syntax extension
pa_bindlib.cmo: bindlib.cmi pa_bindlib.ml 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 pa_bindlib.ml

# 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 pa_o.ml 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 ...