Version française
Home     About     Download     Resources     Contact us    
Browse thread
Obj.t : Illegal instruction (and camlp4)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] Obj.t : Illegal instruction (and camlp4)
Hi,

On Wed, Feb 07, 2007 at 12:47:17PM +1100, Pietro Abate wrote:

> 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))
> ;;

Replace:
    let a = (fun _ _ -> <:expr< "dummy_action" >>) in

by:
    let a =
      List.fold_left (fun a _ -> Obj.magic (fun _ a))
        (Obj.magic (fun _loc -> <:expr< "dummy_action" >>)) token_list
    in

The semantic action must have as many parameters as the length of the
symbols list plus one (the last one being the location of the rule).

-- 
Daniel de Rauglaudre
http://pauillac.inria.fr/~ddr/