From de6786eb28c3034dfef654da73b09358fbd8cd90 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Fri, 29 Oct 2021 16:04:55 +0200 Subject: [PATCH] Allow multiple template bodies --- src/parse/mod.rs | 2 +- tests/ref/code/call.png | Bin 1865 -> 2397 bytes tests/typ/code/call.typ | 5 +++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/parse/mod.rs b/src/parse/mod.rs index cc7102019..8466d99f6 100644 --- a/src/parse/mod.rs +++ b/src/parse/mod.rs @@ -561,7 +561,7 @@ fn call(p: &mut Parser, callee: Expr) -> Option { } }; - if p.peek_direct() == Some(Token::LeftBracket) { + while p.peek_direct() == Some(Token::LeftBracket) { let body = template(p); args.items.push(CallArg::Pos(body)); } diff --git a/tests/ref/code/call.png b/tests/ref/code/call.png index f5e197838f57b46b97232ce1091416b45640777e..bd6f22f325f4db0ec7e5daa2a180be0758e01c3e 100644 GIT binary patch literal 2397 zcmai0doG=t+vdIR zk3>QzN;6@Elh+{fE`~-kBf@p>UFV;>R_E@u*Is*l|LpyJd#}BAlG7>M9ov+*0RXTA zkF#+G05QqU{0C$+08c;M+yekxk$4-+Um^$RhlevB)bExWrHhdOC5tU;68U1BSPtMj z$^raG*%qWCs9c;?zsT}0_e2!=_pgy0UB+i$Q@7vpm|c$6s=$uFjVc{4y&dBu`4dmr z*hX>aVcFkt(2vn;)_FNF)N5{axY()%294$3gSG3(NI4x)_JPk%i`LHeT$i%M?d6QY zA!3@iJ0%mEkcLTs&+CE3E*UuZpU1tm?h}W^If>_#@Z-Z%CoQTZu%W<;(klr9lKUWa zry^T9q*$UoHAG^N7@kTG<7J8!Kodf-*`js$e#D9M=bxGF#uk}x6QA}A1~h^IV7B|) zy^V0mqRQR^!03(z+5x2l0t`j{(ZG5Y-*7;NZRZ6Z1KyggZNMRf1NhccUV2xQ_6vvl;)wVZk zz%I~t#5wuLzsNC8Dp4GED+?PmlYP~fb5*}t3c=2vM8+o}CE8)olT(KvUqM65dMUml zMAs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z~DM4&RpdCe`psvIurUw;G5RN;p73_PvuamIHXeaYd6 zzBY8^IG%VM2Wzhys@ok~b+>^z$+TO|y>&fnp_&U4ynCuWSEL5-dCVj%wWnd9DF-}z zKuZYu48ejaiqRL*6Q92r{%(`Fxaz#1ex)|#F!7dtYqayv*b+&5N0$EyGps>DqyAwg zi}XH5E_VEOTmA-(Wp};XTa&t)MX5e3u(np^=oFbJ7TQRNm*JrYTAl8tGXg2Wb8qnc zV?hdLEJT2N@@!5%bY{9!OI)WRMjXPhRi=v*eYu?%=7?nV$HJxN-(unj-nCnMA-9N2 zqlk&}jL8NXHN2GfqsRLp8~%a@Bs?SEC!Myb0clZN7>44a@878Zj->eT68DVHm5eiW zAiK60p1SK&N5glqpWmL#kJKd}gAV@!rMe_740(rBXuOb90`Gly{nFqsAMKsZNsxt( zk0L1WPq^8uG4S!^%7%3t?_x_f$l**OApRNJ!od<-2qHbhL)wR+M zNiV&01v*~6aJ#uoqFqK2=v$3Go0k3<#TfZ-#z?E6gy|m;&lK(pN^E(HM`b(>*(xw< zYRfWXJ-NKQP}gpnfW{pndRjS!5k*5g5g)RmEz+JSV&L1aZ$y&T-~OjbcMTiABNt2T z9QbuM?U26z@$xIjWvnaLsXcDTA)cv-T76nk z;p+7bdsM_(h@DQ^l6$$k{h;$keaJTcsE5|DMa{|NC*`Z3bXfiNl!DlME8SVSc`|21ZwM*-(Iu;^N{+n&38zAAW3kW5Y9{PVj Nl6uzGqLh4z^$$w+NO=GN diff --git a/tests/typ/code/call.typ b/tests/typ/code/call.typ index ffd917696..5ab0252c0 100644 --- a/tests/typ/code/call.typ +++ b/tests/typ/code/call.typ @@ -20,6 +20,11 @@ #f()[A] #f([A]) +#let g(a, b) = a + b +#g[A][B] +#g([A], [B]) +#g()[A][B] + --- // Trailing comma. #test(1 + 1, 2,)