English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
using a camlp4 man filter with my own type
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-03-05 (15:04)
From: Joel Reymont <joelr1@g...>
Subject: using a camlp4 man filter with my own type
I looked at the Camlp4 filter wiki [1] but still can't figure this out.

+ ocamlfind ocamlc -package 'oUnit, dyp, extlib' -c -I +camlp4 -g -w a  
-pp 'camlp4of -I src -filter map' -I src -o src/easy_type_check.cmo  
File "src/easy_type_check.ml", line 45, characters 10-15:
Error: This expression has no method expr

This used to work fine in 3.10.x and the error points to "match  
super#expr e with" in strip_token_loc below.

	Thanks, Joel


Here's the code...

open Easy_ast
open Easy_symtab

exception TypeCheck_error of string

let type_check_error s = raise (TypeCheck_error s)

(* Type inference *)

let rec infer_type env = function
   | Int _                    -> TyInt
   ... etc

(* Remove annotations for unit testing *)

class map = Camlp4MapGenerator.generated;;

let strip_token_loc = object
   inherit map as super
   method expr e =
     match super#expr e with
       | TokenPos (a, _) -> a
       | e                -> e

let strip_stmt x = strip_token_loc#statement x;;

module Camlp4Trash = struct
   INCLUDE "easy_ast.ml";;

[1] http://brion.inria.fr/gallium/index.php/Camlp4MapGenerator

Mac, C++, OCaml