From 835eaed23c8bb82c4c1d41a662e3eb3c5d984cd8 Mon Sep 17 00:00:00 2001 From: Mingun Date: Wed, 27 Mar 2024 23:09:22 +0500 Subject: [PATCH] Nim, Lua: fix sticking unary "not" operator to the number BaseTranslator does not insert space between operator and expression. When expression is a number, "~" and "!" becomes "not" which is an identifier Fixes test (1): ``` [info] - nim:~777 *** FAILED *** [info] "not[]777" was not equal to "not[ ]777" (TranslatorSpec.scala:183) [info] Analysis: [info] "not[]777" -> "not[ ]777" ``` --- .../scala/io/kaitai/struct/translators/LuaTranslator.scala | 2 +- .../scala/io/kaitai/struct/translators/NimTranslator.scala | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/shared/src/main/scala/io/kaitai/struct/translators/LuaTranslator.scala b/shared/src/main/scala/io/kaitai/struct/translators/LuaTranslator.scala index c25b7d6e7..3553adb18 100644 --- a/shared/src/main/scala/io/kaitai/struct/translators/LuaTranslator.scala +++ b/shared/src/main/scala/io/kaitai/struct/translators/LuaTranslator.scala @@ -185,7 +185,7 @@ class LuaTranslator(provider: TypeProvider, importList: ImportList) extends Base case Ast.boolop.And => "and" } override def unaryOp(op: Ast.unaryop): String = op match { - case Ast.unaryop.Not => "not" + case Ast.unaryop.Not => "not " case _ => super.unaryOp(op) } } diff --git a/shared/src/main/scala/io/kaitai/struct/translators/NimTranslator.scala b/shared/src/main/scala/io/kaitai/struct/translators/NimTranslator.scala index 328315502..e9972b407 100644 --- a/shared/src/main/scala/io/kaitai/struct/translators/NimTranslator.scala +++ b/shared/src/main/scala/io/kaitai/struct/translators/NimTranslator.scala @@ -47,9 +47,9 @@ class NimTranslator(provider: TypeProvider, importList: ImportList) extends Base // Members declared in io.kaitai.struct.translators.CommonMethods override def unaryOp(op: Ast.unaryop): String = op match { - case Ast.unaryop.Invert => "not" + case Ast.unaryop.Invert => "not " case Ast.unaryop.Minus => "-" - case Ast.unaryop.Not => "not" + case Ast.unaryop.Not => "not " } override def booleanOp(op: Ast.boolop): String = op match {