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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Conglun Yao <yaoconglun@g...>
Subject: camlp4 questions
Hi,

While doing my little camlp4 (3.10) practice, I had the following questions:

(1) Is there a simple approach to add some 'open' directive at the beginning
of file.
I know in camp4 (3.09), it could be achieved by modifying
Pcaml.parse_implem.

Pcaml.parse_implem :=
fun strm ->
let (sils, stopped) = Grammar.Entry.parse Pcaml.implem strm in
let enhanced_sils = ..... (* modify sils *)
(enhanced_sils, stopped);

How can I achieve the same effect in 3.10.

(2) How to extend operators like '@', for example if I want to change the
expression
list_1 @ list_2 => List.append list_1 list_2

In 3.09, it could be achieved by deleting rules
DELETE_RULE Gram expr: SELF; "@"; SELF END

however, in 3.10, it seems I can't find the above grammar, only can find in
Camlp4OCamlParser.ml
expr: AFTER "^"
[ "::" RIGHTA
[ e1 = SELF; "::"; e2 = SELF -> <:expr< [$e1$ :: $e2$] >> ]
];

Furthermore, if I want to extend the expr: "["; sem_expr_for_list; "]",
where to find the rule definition.
In 3.09, all of these exist in pa_o.ml

Any suggestion is welcome and appreciated.

Conglun