浏览代码

allow `extern abstract`

Simon Krajewski 9 年之前
父节点
当前提交
9763cc1978
共有 3 个文件被更改,包括 4 次插入1 次删除
  1. 1 0
      ast.ml
  2. 1 1
      parser.ml
  3. 2 0
      typeload.ml

+ 1 - 0
ast.ml

@@ -412,6 +412,7 @@ type abstract_flag =
 	| AFromType of complex_type
 	| AToType of complex_type
 	| AIsType of complex_type
+	| AExtern
 
 type enum_constructor = {
 	ec_name : string;

+ 1 - 1
parser.ml

@@ -623,7 +623,7 @@ and parse_type_decl s =
 				d_data = t;
 			}, punion p1 p2)
 		| [< '(Kwd Abstract,p1); name = type_name; tl = parse_constraint_params; st = parse_abstract_subtype; sl = plist parse_abstract_relations; '(BrOpen,_); fl, p2 = parse_class_fields false p1 >] ->
-			let flags = List.map (fun (_,c) -> match c with EPrivate -> APrivAbstract | EExtern -> error (Custom "extern abstract not allowed") p1) c in
+			let flags = List.map (fun (_,c) -> match c with EPrivate -> APrivAbstract | EExtern -> AExtern) c in
 			let flags = (match st with None -> flags | Some t -> AIsType t :: flags) in
 			(EAbstract {
 				d_name = name;

+ 2 - 0
typeload.ml

@@ -3172,6 +3172,8 @@ let rec init_module_type ctx context_init do_init (decl,p) =
 				(match at with TAbstract(a2,_) when a == a2 -> error "Abstract underlying type cannot be recursive" a.a_pos | _ -> ());
 				a.a_this <- at;
 				is_type := true;
+			| AExtern ->
+				(match a.a_impl with Some c -> c.cl_extern <- true | None -> (* Hmmmm.... *) ())
 			| APrivAbstract -> ()
 		) d.d_flags;
 		if not !is_type then begin