File: q_phony.ml

package info (click to toggle)
camlp4 2.04-3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,576 kB
  • ctags: 3,108
  • sloc: ml: 26,444; makefile: 736; sh: 203
file content (36 lines) | stat: -rw-r--r-- 1,281 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
(* camlp4r pa_extend.cmo q_MLast.cmo *)
(***********************************************************************)
(*                                                                     *)
(*                             Camlp4                                  *)
(*                                                                     *)
(*        Daniel de Rauglaudre, projet Cristal, INRIA Rocquencourt     *)
(*                                                                     *)
(*  Copyright 1998 Institut National de Recherche en Informatique et   *)
(*  Automatique.  Distributed only by permission.                      *)
(*                                                                     *)
(***********************************************************************)

(* $Id: q_phony.ml,v 2.1 1999/04/26 12:34:03 ddr Exp $ *)

open Pcaml;

EXTEND
  expr:
    [[ "tagada"; s = STRING -> <:expr< $lid:s$ >> ]]
  ;
  patt:
    [[ "tagada"; s = STRING -> <:patt< $lid:s$ >> ]]
  ;
END;

value t = ref "";

Quotation.add ""
  (Quotation.ExStr
     (fun _ s ->
        let t = if t.val = "" then "" else ":" ^ t.val in
        "tagada \"<" ^ t ^ "<" ^ String.escaped s ^ ">>\""))
;

Quotation.default.val := "";
Quotation.translate.val := fun s -> do t.val := s; return "";