|
| 1 | +let _ = |
| 2 | + object |
| 3 | + (* some comment *) |
| 4 | + inherit M.t as p [@@attr] |
| 5 | + |
| 6 | + (* some comment *) |
| 7 | + method! x = 2 [@@attr] |
| 8 | + |
| 9 | + method x = (1 [@attr]) |
| 10 | + |
| 11 | + method virtual x : t |
| 12 | + |
| 13 | + method virtual private x : t |
| 14 | + |
| 15 | + method! private x = 3 |
| 16 | + |
| 17 | + method! private x : t = 4 |
| 18 | + |
| 19 | + method! private x : type a b c. r = 5 |
| 20 | + |
| 21 | + method! private x : type a. r = 6 |
| 22 | + |
| 23 | + val virtual x : t |
| 24 | + |
| 25 | + val virtual mutable x : t |
| 26 | + |
| 27 | + val virtual mutable x : t |
| 28 | + |
| 29 | + val! mutable x = 7 |
| 30 | + |
| 31 | + val! mutable x : t = 8 |
| 32 | + |
| 33 | + constraint t = 'a t |
| 34 | + |
| 35 | + [%%ext salut, "hello"] |
| 36 | + |
| 37 | + [@@@attr] |
| 38 | + |
| 39 | + initializer f x ; 9 |
| 40 | + |
| 41 | + initializer |
| 42 | + let x = y in |
| 43 | + z |
| 44 | + |
| 45 | + method x = |
| 46 | + let f = {<a; b = e>} in |
| 47 | + x <- expr |
| 48 | + |
| 49 | + method x : type a b c. (a, b) t -> c = |
| 50 | + let f = {<a; b = e>} in |
| 51 | + x <- expr |
| 52 | + |
| 53 | + method x : (a, b) t -> c = |
| 54 | + let f = |
| 55 | + {< a |
| 56 | + ; b = something very |
| 57 | + loooooooooooooooooooooooooooooooooooooooooooooooong >} |
| 58 | + in |
| 59 | + x <- |
| 60 | + something very |
| 61 | + looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong |
| 62 | + end |
| 63 | + |
| 64 | +let _ = f a#b (a#c x y) |
| 65 | + |
| 66 | +let _ = f a##.b (a##c x y) |
| 67 | + |
| 68 | +type t = (int, int) #q |
| 69 | + |
| 70 | +let _ = object%js end |
| 71 | + |
| 72 | +let _ = object%js (super) end |
| 73 | + |
| 74 | +let _ = object%js (super : 'a) end |
| 75 | + |
| 76 | +let _ = f (object end) |
| 77 | + |
| 78 | +let _ = f (object%js end) |
| 79 | + |
| 80 | +class t ~a = |
| 81 | + object |
| 82 | + inherit f a |
| 83 | + |
| 84 | + method x a b = a + b |
| 85 | + end |
| 86 | + |
| 87 | +class type mapper = [%test] |
| 88 | + |
| 89 | +module type A = sig |
| 90 | + class mapper : int -> x:int -> ?y:int -> object |
| 91 | + method xxxxxxxxxxxxxxxxxxxxxxxxxxx : int |
| 92 | + end |
| 93 | + |
| 94 | + class tttttttttttt : |
| 95 | + aaaaaaaaaaaaaaaaaa:int |
| 96 | + -> bbbbbbbbbbbbbbbbbbbbb:float |
| 97 | + -> cccccccccccccccccccc |
| 98 | + |
| 99 | + class c : object |
| 100 | + inherit ['a a] d |
| 101 | + |
| 102 | + constraint 'a = int |
| 103 | + |
| 104 | + [%%ext something] |
| 105 | + |
| 106 | + [@@@attr something] |
| 107 | + |
| 108 | + val (*x*) virtual (*y*) mutable (*z*) a : int |
| 109 | + |
| 110 | + val (*x*) mutable (*y*) virtual (*z*) a : int |
| 111 | + |
| 112 | + method (*x*) virtual (*y*) private (*z*) b : int -> int -> int |
| 113 | + |
| 114 | + method (*x*) private (*y*) virtual (*z*) b : int -> int -> int |
| 115 | + end |
| 116 | +end |
| 117 | + |
| 118 | +class type mapper = |
| 119 | + let open Modl1 in |
| 120 | +object |
| 121 | + method expression : Javascript.expression -> Javascript.expression |
| 122 | + |
| 123 | + method expression_o : |
| 124 | + Javascript.expression option -> Javascript.expression option |
| 125 | + |
| 126 | + method switch_case : |
| 127 | + Javascript.expression |
| 128 | + -> Javascript.expression |
| 129 | + -> a |
| 130 | + -> b |
| 131 | + -> ccccccccccc |
| 132 | + -> d |
| 133 | + -> e |
| 134 | +end |
| 135 | + |
| 136 | +class tttttttttttttttttttttttttt ~aaaaaaaaaaaaaaaaaaaaaaaaaaaa |
| 137 | + bbbbbbbbbbbbbbbbbbbbb = |
| 138 | + object |
| 139 | + inherit f a |
| 140 | + |
| 141 | + method x a b = a + b |
| 142 | + end |
| 143 | + |
| 144 | +class tttttttttttttttttttttttttt x y = |
| 145 | + let open Mod in |
| 146 | + let x = 2 in |
| 147 | + let f x = |
| 148 | + object |
| 149 | + inherit f a |
| 150 | + |
| 151 | + method x a b = a + b |
| 152 | + end |
| 153 | + in |
| 154 | + f 0 |
| 155 | + |
| 156 | +class tttttttttttttttttttttttttt x y = |
| 157 | + let open Mod in |
| 158 | + let x = 2 in |
| 159 | + (fun x -> |
| 160 | + object |
| 161 | + inherit f a |
| 162 | + |
| 163 | + method x a b = a + b |
| 164 | + end ) |
| 165 | + 0 |
| 166 | + |
| 167 | +class c = |
| 168 | + object |
| 169 | + (** about a *) |
| 170 | + method a : type a b c. d -> e -> f = g |
| 171 | + |
| 172 | + (** floatting *) |
| 173 | + |
| 174 | + (** about a *) |
| 175 | + method a : 'a. d -> e -> f = g |
| 176 | + end |
| 177 | + |
| 178 | +(** about a *) |
| 179 | +class a = object end |
| 180 | + |
| 181 | +(** floatting *) |
| 182 | + |
| 183 | +(** about b *) |
| 184 | +and b = object end |
| 185 | + |
| 186 | +class type x = object |
| 187 | + (** floatting1 *) |
| 188 | + |
| 189 | + (** floatting2 *) |
| 190 | + |
| 191 | + method x : int |
| 192 | + |
| 193 | + (** floatting3 *) |
| 194 | +end |
| 195 | + |
| 196 | +class x = |
| 197 | + object |
| 198 | + |
| 199 | + (** floatting1 *) |
| 200 | + |
| 201 | + (** floatting2 *) |
| 202 | + |
| 203 | + method x = 2 |
| 204 | + |
| 205 | + (** floatting3 *) |
| 206 | + end |
| 207 | + |
| 208 | +let _ = f ##= (fun x -> x) |
| 209 | + |
| 210 | +let o = |
| 211 | + object |
| 212 | + method int_bin_op |
| 213 | + : int t * [`Plus | `Minus | `Mult | `Div | `Mod] * int t -> int t = |
| 214 | + fun (a, op, b) -> Int_bin_op (self#expression a, op, self#expression b) |
| 215 | + |
| 216 | + method int_bin_comparison aaaaaaaaaaaaaaaa bbbbbbbbbbbbbbbbbbbb |
| 217 | + ccccccccccccccccccccc ddddddddddddddddddddddddd |
| 218 | + : int t * [`Eq | `Ne | `Gt | `Ge | `Lt | `Le] * int ttttttttt |
| 219 | + -> bool tttttttttttttttt rrrrrrrrrrrrrrrrrrrrr |
| 220 | + rrrrrrrrrrrrrrrrrrrrr |
| 221 | + rrrrrrrrrrrrrrrrrrrrrrr = |
| 222 | + fun (a, op, b) -> |
| 223 | + Int_bin_comparison (self#expression a, op, self#expression b) |
| 224 | + end |
| 225 | + |
| 226 | +class f = fun [@inline] (b [@inline]) -> object end |
| 227 | + |
| 228 | +class f = [%test] [@test] |
| 229 | + |
| 230 | +class f a (b [@inline]) = object end |
| 231 | + |
| 232 | +class f = |
| 233 | + object (self) |
| 234 | + inherit [a] c (f 1) (fun x -> x) (match x with x -> x) as p |
| 235 | + end |
| 236 | + |
| 237 | +class f ((i, o) as io) = |
| 238 | + object (self) |
| 239 | + inherit [a] c (f 1) (fun x -> x) (match x with x -> x) as p |
| 240 | + end |
| 241 | + |
| 242 | +class type ['a] tsv = object |
| 243 | + inherit [ < sep: [`tab] ; comment: [`sharp] ; .. > as 'a] tabular |
| 244 | +end |
| 245 | +;; |
| 246 | + |
| 247 | +{< (* Debug.print ("free var: "^string_of_int x); *) |
| 248 | + free_vars = IntSet.add x free_vars >} |
| 249 | +;; |
| 250 | + |
| 251 | +{<(* Debug.print ("free var: "^string_of_int x); *) free_vars>} ;; |
| 252 | + |
| 253 | +{< (* Debug.print ("free var: "^string_of_int x); *) |
| 254 | + very_loooooooooooong_identifier >} |
| 255 | +;; |
| 256 | + |
| 257 | +{< (* Debug.print ("free var: "^string_of_int x); *) |
| 258 | + x = (Some k : t) |
| 259 | + ; (* Debug.print ("free var: "^string_of_int x); *) |
| 260 | + y = yet another value >} |
| 261 | +;; |
| 262 | + |
| 263 | +{< (* check: e is effectively the index associated with e, and check that |
| 264 | + already in *) |
| 265 | + x = y >} |
| 266 | + |
| 267 | +class type a = b[@attr] |
| 268 | + |
| 269 | +class type a = object end[@attr] |
| 270 | + |
| 271 | +(* Syntax error: class type a = b -> c[@attr] *) |
| 272 | +(* Cannot attach attribute: class a : b -> c = d *) |
| 273 | + |
| 274 | +class type a = [%ext][@attr] |
| 275 | + |
| 276 | +class type a = |
| 277 | + let open[@attr] A in |
| 278 | + b |
| 279 | + |
| 280 | +class a = |
| 281 | + let open[@attr] A in |
| 282 | + b |
| 283 | + |
| 284 | +class t (lazy _) = object end |
| 285 | + |
| 286 | +class virtual c = |
| 287 | + let (mc_exit : _) = () in |
| 288 | + object end |
| 289 | + |
| 290 | +(* Fitting *) |
| 291 | + |
| 292 | +class a = object end |
| 293 | + |
| 294 | +class a x = object end |
| 295 | + |
| 296 | +class a x = object end |
| 297 | + |
| 298 | +class a x = object (self) end |
| 299 | + |
| 300 | +let x = |
| 301 | + fun [@foo] x -> |
| 302 | + fun [@foo] y -> |
| 303 | + object |
| 304 | + method x = y |
| 305 | + end |
| 306 | + |
| 307 | +class x = |
| 308 | + fun [@foo] x -> |
| 309 | + fun [@foo] y -> |
| 310 | + object |
| 311 | + method x = y |
| 312 | + end |
0 commit comments