Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 92 lines (72 sloc) 2.222 kB
adda7d2 jslib + changes from my repository
Jake Donham authored
1 (*
2 * This file is part of ocamljs, OCaml to Javascript compiler
3 * Copyright (C) 2007 Skydeck, Inc
4 *
5 * This program is free software released under the QPL.
6 * See LICENSE for more details.
7 *
8 * The Software is provided AS IS with NO WARRANTY OF ANY KIND,
9 * INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND
10 * FITNESS FOR A PARTICULAR PURPOSE.
11 *)
12
13 open Camlp4.PreCast
14 module Jslib_ast =
15 struct
16
17 type loc = Loc.t
18
aa568d8 support for inline javascript
Jake Donham authored
19 INCLUDE "../jslib_ast.incl"
adda7d2 jslib + changes from my repository
Jake Donham authored
20
21 end
22
23 include Jslib_ast
24
25 module Meta =
26 struct
27
28 (* I don't really understand what's going on here but this is how
29 Camlp4Ast.mlast does it. *)
30
31 module type META_LOC =
32 sig
33 val meta_loc_patt : Loc.t -> Loc.t -> Ast.patt
34 val meta_loc_expr : Loc.t -> Loc.t -> Ast.expr
35 end
36
37 module MetaLoc =
38 struct
39 let meta_loc_patt _loc location =
40 let (a, b, c, d, e, f, g, h) = Loc.to_tuple location in
41 <:patt< Loc.of_tuple
42 ($`str:a$, $`int:b$, $`int:c$, $`int:d$,
43 $`int:e$, $`int:f$, $`int:g$,
44 $if h then <:patt< True >> else <:patt< False >> $) >>
45 let meta_loc_expr _loc location =
46 let (a, b, c, d, e, f, g, h) = Loc.to_tuple location in
47 <:expr< Loc.of_tuple
48 ($`str:a$, $`int:b$, $`int:c$, $`int:d$,
49 $`int:e$, $`int:f$, $`int:g$,
50 $if h then <:expr< True >> else <:expr< False >> $) >>
51 end
52
53 module MetaGhostLoc =
54 struct
55 let meta_loc_patt _loc _ = <:patt< Loc.ghost >>
56 let meta_loc_expr _loc _ = <:expr< Loc.ghost >>
57 end
58
59 module MetaLocVar = struct
60 let meta_loc_patt _loc _ = <:patt< $lid:!Loc.name$ >>
61 let meta_loc_expr _loc _ = <:expr< $lid:!Loc.name$ >>
62 end
63
64 module Make (MetaLoc : META_LOC) =
65 struct
66 open MetaLoc
67
68 module Expr =
69 struct
70 let meta_loc = meta_loc_expr
71
72 let meta_option mf_a _loc = function
73 | None -> <:expr< None >>
74 | Some a -> <:expr< Some $mf_a _loc a$ >>
75
76 include Camlp4Filters.MetaGeneratorExpr(Jslib_ast)
77 end
78
79 module Patt =
80 struct
81 let meta_loc = meta_loc_patt
82
83 let meta_option mf_a _loc = function
84 | None -> <:patt< None >>
85 | Some a -> <:patt< Some $mf_a _loc a$ >>
86
87 include Camlp4Filters.MetaGeneratorPatt(Jslib_ast)
88 end
89 end
90
91 end
Something went wrong with that request. Please try again.