From 433dde73b0713c6830ec7abf649c7e0733d906fc Mon Sep 17 00:00:00 2001 From: Softonik Date: Thu, 8 Dec 2022 04:26:28 +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=D0=BE=20=D0=BF=D1=80=D1=81=D0=B2=D0=BE=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20=D0=BC?= =?UTF-8?q?=D0=B0=D1=81=D1=81=D0=B8=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- transpile_python/service.go | 6 ++++++ transpile_python/service_test.go | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/transpile_python/service.go b/transpile_python/service.go index 8ea0ac8..6870ae7 100644 --- a/transpile_python/service.go +++ b/transpile_python/service.go @@ -136,6 +136,10 @@ func handleBasicLit(bl *ast.BasicLit) string { return bl.Value } +func handleCompositeLit(bl *ast.CompositeLit) string { + return "[]" +} + func handleUnaryExpr(expr *ast.UnaryExpr) string { code := expr.Op.String() code += handleExpr(expr.X) @@ -194,6 +198,8 @@ func handleExpr(expr ast.Expr) string { switch e := expr.(type) { case *ast.BasicLit: code += handleBasicLit(e) + case *ast.CompositeLit: + code += handleCompositeLit(e) case *ast.UnaryExpr: code += handleUnaryExpr(e) case *ast.BinaryExpr: diff --git a/transpile_python/service_test.go b/transpile_python/service_test.go index 3f32750..12c231d 100644 --- a/transpile_python/service_test.go +++ b/transpile_python/service_test.go @@ -98,6 +98,25 @@ main() Compare(source, expected) }) + It("Array assignment", func() { + source := `package test + import "skidl" + + func main() { + a := []any{} + a = []any{} + } + ` + expected := `from skidl import * + +def main(): + a = [] + a = [] +main() +` + Compare(source, expected) + }) + It("Function Declaration", func() { source := `package test import "skidl"