@@ -137,6 +137,15 @@ hello
137137#{ a => b }
138138```
139139
140+ ## Matching of ...:
141+
142+ ```
143+ 1> lists:seq(1,100).
144+ [1, 2, 3 | ...]
145+ 2> #{ a => b }.
146+ #{ a => ... }
147+ ```
148+
140149## Edge cases:
141150
142151```
@@ -192,7 +201,8 @@ module(#docs_v1{ docs = Docs, module_doc = MD }, Bindings) ->
192201 N ->
193202 error ({N ,errors })
194203 end .
195-
204+ print_error ({{Name ,Arity },{Message ,Line ,Context }}) ->
205+ io :format (" ~p /~p :~p : ~ts~n~ts~n " , [Name ,Arity ,Line ,Context ,Message ]);
196206print_error ({{Name ,Arity },{Message ,Context }}) ->
197207 io :format (" ~p /~p : ~ts~n~ts~n " , [Name ,Arity ,Context ,Message ]).
198208
@@ -346,17 +356,26 @@ parse(Cmd0, _Test, _Match) ->
346356 Cmd = lists :flatten (Cmd0 ),
347357 maybe
348358 {ok , T , _ } ?= erl_scan :string (Cmd ),
349- {ok , Ast } ?= inspect (erl_parse :parse_exprs (T )),
359+ RewrittenToks = rewrite_tokens (T ),
360+ {ok , Ast } ?= inspect (erl_parse :parse_exprs (RewrittenToks )),
350361 Ast
351362 else
352- {error , {_Line ,Mod ,Reason }, _ } ->
363+ {error , {Line ,Mod ,Reason }, _ } ->
353364 Message = Mod :format_error (Reason ),
354- throw ({error ,{Message ,Cmd }});
355- {error , {_Line ,Mod ,Reason }} ->
365+ throw ({error ,{Message ,Line , Cmd }});
366+ {error , {Line ,Mod ,Reason }} ->
356367 Message = Mod :format_error (Reason ),
357- throw ({error ,{Message ,Cmd }})
368+ throw ({error ,{Message ,Line , Cmd }})
358369 end .
359370
371+ % % We rewrite ... to _ to match shell syntax better
372+ rewrite_tokens ([{'...' , L } | T ]) ->
373+ rewrite_tokens ([{var , L , '_' } | T ]);
374+ rewrite_tokens ([H | T ]) ->
375+ [H | rewrite_tokens (T )];
376+ rewrite_tokens ([]) ->
377+ [].
378+
360379format_exception (Class , Reason , [{M ,F ,A ,Info0 },Item |_ ]) ->
361380 Info = lists :keydelete (line , 1 , Info0 ),
362381 Stacktrace = [{M ,F ,A ,Info },Item ],
0 commit comments