From dbd6fb8eac7b069f34809e11c92d0aa573c9fe77 Mon Sep 17 00:00:00 2001 From: Softonik Date: Thu, 8 Dec 2022 04:16:36 +0300 Subject: [PATCH] =?UTF-8?q?Python:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5=20=D0=B8=20=D0=BF=D1=80=D0=B8=D1=81=D0=B2?= =?UTF-8?q?=D0=B0=D0=B8=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=82=D0=B8=D0=BF?= =?UTF-8?q?=D0=B0=20bool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- transpile_python/service.go | 12 ++++++++++++ transpile_python/service_test.go | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/transpile_python/service.go b/transpile_python/service.go index 49a2a92..8ea0ac8 100644 --- a/transpile_python/service.go +++ b/transpile_python/service.go @@ -390,6 +390,10 @@ func handleIdent(expr ast.Expr) string { switch ident.Name { case "string": code += "" + case "true": + code += "True" + case "false": + code += "False" default: code += ident.Name } @@ -594,6 +598,9 @@ func handleValueSpecType(expr ast.Expr) string { code += handleSelectorExpr(t) case *ast.Ident: code += handleIdent(t) + default: + spew.Dump(expr) + code += "unknown handleValueSpecType" } return code } @@ -610,6 +617,11 @@ func handleValueSpecValues(values []ast.Expr) string { code += handleSelectorExpr(value) case *ast.CallExpr: code += handleCallExpr(v) + case *ast.Ident: + code += handleIdent(v) + default: + spew.Dump(value) + code += "unknown handleValueSpecValues" } } return code diff --git a/transpile_python/service_test.go b/transpile_python/service_test.go index 95214c0..3f32750 100644 --- a/transpile_python/service_test.go +++ b/transpile_python/service_test.go @@ -61,6 +61,8 @@ main() b = 2 c = 3 d = a + b + c / 2 + t = true + f = false ) ` expected := `from skidl import * @@ -69,7 +71,28 @@ a = 1 b = 2 c = 3 d = a + b + c / 2 +t = True +f = False +main() +` + Compare(source, expected) + }) + + It("Simple bool assignment", func() { + source := `package test + import "skidl" + + func main() { + t := true + o = true + } + ` + expected := `from skidl import * + +def main(): + t = True + o = True main() ` Compare(source, expected)