Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 114 lines (90 sloc) 2.745 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (**
19 Printer for JsAst, and functor for serialization of js.
20 @author Maxime Audoin (previous version)
21 @author Mathieu Barbin, adapted for OPA from ocamljs/jslib
22 *)
23
24 (**
25 exported because used by:
26 ??
27 *)
28 val string_of_ident : JsAst.ident -> string
29
30 val escape_string : ?double_quote:bool -> string -> string
31
32 (** {6 Pretty printer} *)
33
34 (**
35 Standard pprinter type
36 *)
37 type 'a pprinter = Format.formatter -> 'a -> unit
38
39 (**
40 For standard js only. Such opa construction, as 'hole' are not supported by this printer ( [assert false] )
41 *)
42 class printer :
43 object
44 method ident : JsAst.ident pprinter
45 method unop : JsAst.unop pprinter
46 method field : string pprinter
47 method objpart : (string * JsAst.expr) pprinter
48 method pexpr : leading:bool -> int -> JsAst.expr pprinter
49 method block : JsAst.statement list pprinter
50 method expr : leading:bool -> JsAst.expr pprinter
51 method statements : JsAst.statement list pprinter
52 method statement : JsAst.statement pprinter
53 method code : JsAst.code pprinter
54 end
55
56 val pp : printer
57
58 (** same as pp, but prints the blocks instead of hiding them *)
59 val debug_pp : printer
60
61 (** {6 Stringfier} *)
62
63 (**
64 TODO:
65 who does need this ?
66 maybe do not export this.
67 *)
68
69 (**
70 code
71 *)
72 val code : JsAst.code -> string
73
74 (** {6 Partial Printer} *)
75
76 (**
77 Js Runtime Serializer.
78
79 This is used for serializing js with some hole.
80 Hole correspond to different kind of lexems which evaluates as string representing
81 js code as concrete syntax.
82 *)
83
84 module type X =
85 sig
86 (**
87 The type of one lexem
88 *)
89 type lexem
90 type t
91 val append : t -> lexem -> t
92 val empty : t
93
94
95 (** {6 Nodes} *)
96 (**
97 We can extend this interface, if we need more precise js ast at runtime.
98 Invariant: in the returned t, there are no 2 successives lexem verbatim.
99 *)
100
101 val ident : string -> lexem
102 val verbatim : string -> lexem
103 val qml : QmlAst.expr -> lexem
104 val serialized : JsAstRuntime.expr -> lexem list
105 end
106
107 module type S =
108 sig
109 type t
110 val code_elt : JsAst.code_elt -> t
111 end
112
113 module Make : functor (X : X) -> S with type t = X.t
Something went wrong with that request. Please try again.