@@ -11,22 +11,6 @@ function is_stringchunk(node)
11
11
return k == K " String" || k == K " CmdString"
12
12
end
13
13
14
- function lower_underscores (args, skiparg= - 1 )
15
- g = nothing
16
- for i in 1 : length (args)
17
- if i == skiparg
18
- continue
19
- end
20
- if args[i] == :_
21
- if isnothing (g)
22
- g = gensym ()
23
- end
24
- args[i] = g
25
- end
26
- end
27
- return g
28
- end
29
-
30
14
function reorder_parameters! (args, params_pos)
31
15
p = 0
32
16
for i = length (args): - 1 : 1
@@ -206,7 +190,6 @@ function _to_expr(node::SyntaxNode; iteration_spec=false, need_linenodes=true,
206
190
headsym = Symbol (" '" )
207
191
end
208
192
# Move parameters blocks to args[2]
209
- g = lower_underscores (args, 1 )
210
193
reorder_parameters! (args, 2 )
211
194
if headsym === :dotcall
212
195
if is_prefix_call (node)
@@ -217,17 +200,9 @@ function _to_expr(node::SyntaxNode; iteration_spec=false, need_linenodes=true,
217
200
args[1 ] = Symbol (" ." , args[1 ])
218
201
end
219
202
end
220
- if ! isnothing (g)
221
- return Expr (:-> , g, Expr (:call , args... ))
222
- end
223
203
elseif headsym in (:ref , :curly )
224
204
# Move parameters blocks to args[2]
225
205
reorder_parameters! (args, 2 )
226
- elseif headsym == :.
227
- g = lower_underscores (args)
228
- if ! isnothing (g)
229
- return Expr (:-> , g, Expr (:., args... ))
230
- end
231
206
elseif headsym in (:tuple , :vect , :braces )
232
207
# Move parameters blocks to args[1]
233
208
reorder_parameters! (args, 1 )
@@ -352,13 +327,37 @@ function _to_expr(node::SyntaxNode; iteration_spec=false, need_linenodes=true,
352
327
headsym = :const
353
328
end
354
329
elseif headsym == Symbol (" />" ) || headsym == Symbol (" \\ >" )
355
- freearg = gensym ()
356
330
callex = only (args)
357
331
@assert Meta. isexpr (callex, :call )
358
332
args = callex. args
359
333
func = headsym == Symbol (" />" ) ?
360
334
:(JuliaSyntax. fixbutfirst) :
361
335
:(JuliaSyntax. fixbutlast)
336
+
337
+ # Automatic underscore lowering within pipes
338
+ for i = 2 : length (args)
339
+ anon_args = Symbol[]
340
+ if i == 2 && Meta. isexpr (args[i], :parameters )
341
+ kws = args[i]. args
342
+ for j = 1 : length (kws)
343
+ kw = kws[j]
344
+ if Meta. isexpr (kw, :kw )
345
+ as = Any[kw. args[2 ]]
346
+ lower_underscores! (anon_args, as)
347
+ if ! isempty (anon_args)
348
+ kw. args[2 ] = Expr (:-> , Expr (:tuple , anon_args... ), as[1 ])
349
+ end
350
+ end
351
+ end
352
+ else
353
+ as = Any[args[i]]
354
+ lower_underscores! (anon_args, as)
355
+ if ! isempty (anon_args)
356
+ args[i] = Expr (:-> , Expr (:tuple , anon_args... ), as[1 ])
357
+ end
358
+ end
359
+ end
360
+
362
361
if length (args) >= 2 && Meta. isexpr (args[2 ], :parameters )
363
362
return Expr (:call , func, args[2 ], args[1 ], args[3 : end ]. .. )
364
363
else
0 commit comments