Hi all, I hope somebody can answer this one... I'm trying to write a small proof of concept pre-processor that modifies the grammar on the fly giving an initial specification and the parse the rest of the file by using this extended grammar. I've managed to extend the grammar and to parse an instruction by using this extended grammar, but now I'm stuck when trying to applying a camlp4 action (Gramext.action). I think that the problem is related to the fact that Gramext.action is of type Obj.t and I'm not really experience with this kind of problems. Briefly, this is the incriminated piece of code (the entire file is attached). let make_entry rt (token_list,action) = let _loc = Token.dummy_loc in let el = List.map (make_token rt) token_list in let a = (fun _ _ -> <:expr< "dummy_action" >>) in (el,Gramext.action (Obj.repr a)) ;; let add_rule label entrylist = let lobj = match label with |"expr" -> Grammar.Entry.obj expr_term | _ -> create_obj label in Grammar.extend [ (lobj, None, [None, None, (List.map (make_entry label) entrylist) ]) ] ;; add_rule basically extend the grammar (EXTEND statement in camlp4) by calling make_entry, that for each rule creates a list of entry of type Gramext.g_symbol and an action of type Gramext.g_action . The action should be a function ('a -> MLast.expr) where 'a is related to the number of arguments associated with the specific rule (I think). To compile the extension: camlp4o pa_extend.cmo q_MLast.cmo pr_o.cmo extbnf.ml > pa_extbnf.ml ocamlfind ocamlc -package camlp4 camlp4.cma str.cma pa_extbnf.ml this is my test file: ------ testfile.ml ----- GRAMMAR expr := expr & expr | VAR ; END let a = term ( A & B ) ;; ------------------------- If I try to use the pre-processor on this file: camlp4o -I . q_MLast.cmo pr_o.cmo pa_extbnf.cmo testfile.ml I simply get "Illegal instruction" Help :) p ps: I hope not to answer myself again in a few hours :) -- ++ Blog: http://blog.rsise.anu.edu.au/?q=pietro ++ ++ "All great truths begin as blasphemies." -George Bernard Shaw ++ Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.html