From 37d8678d7266fd517953d3db39e30ff8775ade7f Mon Sep 17 00:00:00 2001 From: László Németh <nemeth@numbertext.org> Date: Sun, 4 Dec 2022 20:33:36 +0100 Subject: LibreLogo: fix parsing argument of default Logo commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Functions didn't work in arguments of several default Logo commands (mostly turtle moving and setting). A simple example, which resulted an error message: FORWARD RANDOM 100 Regression from commit 740b99783b5480fcd1e5fce7c1beb5967d015041 "tdf#120413 LibreLogo: handle complex Logo expressions". Change-Id: Icb4aece1a5b0343384ce179c27f170eef7d8938c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143642 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org> --- librelogo/source/LibreLogo/LibreLogo.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'librelogo') diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py index 717df1a968a1..5f0c2261f614 100644 --- a/librelogo/source/LibreLogo/LibreLogo.py +++ b/librelogo/source/LibreLogo/LibreLogo.py @@ -2211,8 +2211,14 @@ def __compil__(s): # atom: other tokens (variable names, numbers and function names) atom = {key: value for (key, value) in [j.span() for j in list(atoms.finditer(i))]} par = {"pos": 0, "out": "", "sub": sub, "op": op, "atom": atom, "names": names} - __l2p__(i, par, False, False) - i = par["out"] + if i.startswith(')') and '(' in i: + # replace ")forward(" etc. with spaces temporarily + len_name = i.index('(') + 1 + __l2p__(' ' * len_name + i[len_name:], par, False, False) + i = i[:len_name] + par["out"].lstrip() + else: + __l2p__(i, par, False, False) + i = par["out"] # starting program block if i[0:1] == '[': i = i[1:] -- cgit