@@ -724,14 +724,33 @@ Erlang code.
724
724
check_body ([]) -> [{atom , 0 , nil }];
725
725
check_body (Else ) -> Else .
726
726
727
+ check_partial (Args ) ->
728
+ {NewArgs , PartialArgsCounter } = lists :mapfoldl (fun ({identifier , Line , '_' }, Counter ) -> {{identifier , Line , list_to_atom (lists :concat ([" ?" , Counter ]))}, Counter + 1 };
729
+ (Arg , Counter ) -> {Arg , Counter } end , 0 , Args ),
730
+ if PartialArgsCounter < 1 ->
731
+ false ;
732
+ true ->
733
+ {PartialArgs , _ } = lists :mapfoldl (fun ({identifier , Line , '_' }, Counter ) -> {{identifier , Line , list_to_atom (lists :concat ([" ?" , Counter ]))}, Counter + 1 };
734
+ (_ , Counter ) -> {arg , Counter } end , 0 , Args ),
735
+ {lists :filter (fun is_tuple /1 , PartialArgs ), NewArgs }
736
+ end .
737
+
727
738
build_identifier (Thing ) ->
728
739
{ identifier , ? line (Thing ), ? chars (Thing ) }.
729
740
741
+ build_partial (Parent , Args , Body ) ->
742
+ build_fun (Parent , build_clause (Parent , Args , [], [Body ])).
743
+
730
744
build_bracket_call (Expr , Args ) ->
731
745
build_method_call (Expr , { identifier , element (1 , Args ), '[]' }, element (2 , Args )).
732
746
733
747
build_fun_call (Target , Args ) ->
734
- { fun_call , ? line (Target ), Target , Args }.
748
+ case check_partial (Args ) of
749
+ false ->
750
+ { fun_call , ? line (Target ), Target , Args };
751
+ {PartialFnArgs , NewArgs } ->
752
+ build_partial (Target , PartialFnArgs , { fun_call , ? line (Target ), Target , NewArgs })
753
+ end .
735
754
736
755
build_try (Begin , Exprs ) ->
737
756
{ 'try' , ? line (Begin ), Exprs }.
@@ -790,10 +809,20 @@ build_anonymous_def_method(Def, Args, Clauses) ->
790
809
{ def_method , ? line (Def ), [], length (Args ), [Clauses ] }.
791
810
792
811
build_method_call (Expr , Name , Args ) ->
793
- { method_call , ? line (Name ), ? chars (Name ), Args , Expr }.
812
+ case check_partial (Args ) of
813
+ false ->
814
+ { method_call , ? line (Name ), ? chars (Name ), Args , Expr };
815
+ {PartialFnArgs , NewArgs } ->
816
+ build_partial (Name , PartialFnArgs , { method_call , ? line (Name ), ? chars (Name ), NewArgs , Expr })
817
+ end .
794
818
795
819
build_sharp_call (Left , Right , Args ) ->
796
- { bind_call , ? line (Right ), Left , Right , Args }.
820
+ case check_partial (Args ) of
821
+ false ->
822
+ { bind_call , ? line (Right ), Left , Right , Args };
823
+ {PartialFnArgs , NewArgs } ->
824
+ build_partial (Right , PartialFnArgs , { bind_call , ? line (Right ), Left , Right , NewArgs })
825
+ end .
797
826
798
827
build_local_call (Name , Args ) ->
799
828
{ local_call , ? line (Name ), ? chars (Name ), Args }.
@@ -848,4 +877,4 @@ build_bin(Line, Elements) ->
848
877
{ bin , Line , Elements }.
849
878
850
879
build_bin_element (Expr , Type , Specifier ) ->
851
- { bin_element , ? line (Expr ), Expr , Type , Specifier }.
880
+ { bin_element , ? line (Expr ), Expr , Type , Specifier }.
0 commit comments