summaryrefslogtreecommitdiff
path: root/librelogo
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2013-10-25 08:30:30 +0200
committerLászló Németh <nemeth@numbertext.org>2013-10-25 08:30:30 +0200
commit7744c4a0016be338c6c14b14f620d8af7d76111e (patch)
tree15f422bd0115be8829328913fe50bcaf13120fb7 /librelogo
parent324b47aabcddc75e98ef56769e24362668e26ebc (diff)
librelogo: fix division with measurements
Change-Id: I2204002533bbb3e7c801b3228b0310a42b19a882
Diffstat (limited to 'librelogo')
-rw-r--r--librelogo/source/LibreLogo/LibreLogo.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/librelogo/source/LibreLogo/LibreLogo.py b/librelogo/source/LibreLogo/LibreLogo.py
index 9ad56222f6b1..f46f12701e85 100644
--- a/librelogo/source/LibreLogo/LibreLogo.py
+++ b/librelogo/source/LibreLogo/LibreLogo.py
@@ -1413,7 +1413,7 @@ def __loadlang__(lang, a):
[r"(?<=\n)__repeat__([^\n]*\w[^\n]*):(?=\n)", "for %s in range(1, 1+int(\\1)):" % repcount], # repeat block
[r"(?<=\d)[%s](?=\d)" % a['DECIMAL'], "."], # decimal sign
[r"(?<!/)/(?!/)", "*1.0/"], # fix division: /1 -> /1.0, but not with //
- [r"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['HOUR'], "\\1*30"], # 12h = 12*30°
+ [r"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['HOUR'], lambda r: str(float(r.group(1).replace(",", "."))*30)], # 12h = 12*30°
[r"(?<=\d)(%s)" % a['DEG'], ""], # 1° -> 1
[r"(?<!:)\b(?:__def__)[ \t]+(\w+)\b[ \t]*([:]?\w[^\n]*)", "\ndef \\1(\\2):\n["],
[r"(?<!:)\b(?:__def__)\s+(\w+)", "\ndef \\1():\n["],
@@ -1486,9 +1486,9 @@ def __loadlang__(lang, a):
[r"(?<!:)\b(?:%s)\b" % a['PRINT'], "\n)Print("],
[r"(?<!:)\b(?:%s)\b" % a['TURNLEFT'], "\n)turnleft("],
[r"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['PT'], "\\1"],
- [r"\b([0-9]+([,.][0-9]+)?)(%s)(?!\w)" % a['INCH'], "\\1*72"],
- [r"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['MM'], "\\1*%s" % __MM_TO_PT__],
- [r"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['CM'], "\\1*%s*10" % __MM_TO_PT__],
+ [r"\b([0-9]+([,.][0-9]+)?)(%s)(?!\w)" % a['INCH'], lambda r: str(float(r.group(1).replace(",", "."))*72)],
+ [r"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['MM'], lambda r: str(float(r.group(1).replace(",", "."))*__MM_TO_PT__)],
+ [r"\b([0-9]+([,.][0-9]+)?)(%s)\b" % a['CM'], lambda r: str(float(r.group(1).replace(",", "."))*__MM_TO_PT__*10)],
[r"\b(__(?:int|float|string)__len|round|abs|sin|cos|sqrt|set|list|tuple|sorted)\b ((?:\w|\d+([,.]\d+)?|0[xX][0-9a-fA-F]+|[-+*/]| )+)\)" , "\\1(\\2))" ], # fix parsing: (1 + sqrt x) -> (1 + sqrt(x))
[r"(?<=[-*/=+,]) ?\n\)(\w+)\(", "\\1()"], # read attributes, eg. x = fillcolor
[r"(?<=return) ?\n\)(\w+)\(", "\\1()"], # return + user function