From a0df9ab3d7c9b301f717eaea2455613d60d3dec3 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Wed, 12 May 2010 09:44:28 +0000 Subject: OTP-8629 stdlib: prepare erl_parse.yrl for future extension --- lib/stdlib/src/erl_parse.yrl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/stdlib') diff --git a/lib/stdlib/src/erl_parse.yrl b/lib/stdlib/src/erl_parse.yrl index 69807aad83..5287f55e59 100644 --- a/lib/stdlib/src/erl_parse.yrl +++ b/lib/stdlib/src/erl_parse.yrl @@ -112,6 +112,7 @@ type_guards -> type_guard ',' type_guards : ['$1'|'$3']. type_guard -> atom '(' top_types ')' : {type, ?line('$1'), constraint, ['$1', '$3']}. +type_guard -> var '::' top_type : build_def('$1', '$3'). top_types -> top_type : ['$1']. top_types -> top_type ',' top_types : ['$1'|'$3']. @@ -597,6 +598,10 @@ find_arity_from_specs([Spec|_]) -> {type, _, 'fun', [{type, _, product, Args},_]} = Fun, length(Args). +build_def(LHS, Types) -> + IsSubType = {atom, ?line(LHS), is_subtype}, + {type, ?line(LHS), constraint, [IsSubType, [LHS, Types]]}. + lift_unions(T1, {type, _La, union, List}) -> {type, ?line(T1), union, [T1|List]}; lift_unions(T1, T2) -> -- cgit v1.2.3