summaryrefslogtreecommitdiff
path: root/librelogo
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2022-12-04 20:33:36 +0100
committerLászló Németh <nemeth@numbertext.org>2022-12-05 16:16:09 +0000
commit37d8678d7266fd517953d3db39e30ff8775ade7f (patch)
tree4cb492b69990b3c25ca509fd4f894a7ce0aeca46 /librelogo
parent81ce66ab5d77b0171245e05ed609f2305ce89600 (diff)
LibreLogo: fix parsing argument of default Logo commands
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>
Diffstat (limited to 'librelogo')
-rw-r--r--librelogo/source/LibreLogo/LibreLogo.py10
1 files changed, 8 insertions, 2 deletions
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:]