Python: селекторы (через точку .) выдаются на новой строке

Этот коммит содержится в:
Softonik 2022-12-11 01:04:59 +03:00 коммит произвёл Nikolay Kopitonenko
родитель 3fe7d47388
коммит 686ef65fd7
2 изменённых файлов: 39 добавлений и 12 удалений

Просмотреть файл

@ -48,7 +48,6 @@ func (s *defaultService) Start() error {
if s.out == nil {
return fmt.Errorf("Error: %s", ErrorWorkerWriterIsNil)
}
ind = 0
main_func_declared = false
// Read tokens from file by using Go's parser.
fset := token.NewFileSet()
@ -71,6 +70,7 @@ func (s *defaultService) Start() error {
// Start a transpile with an individual channel for each declaration in the source file.
go func() {
for i, decl := range file.Decls {
ind = 0
handleDecl(i, decl, dst[i], done)
}
}()
@ -112,6 +112,11 @@ func indSpaces() string {
}
return res
}
func indSpacesPlus() string {
increaseInd()
defer decreaseInd()
return indSpaces()
}
func handleAssignStmt(as *ast.AssignStmt) string {
code := handleAssignStmtExpr(as.Lhs)
@ -488,7 +493,8 @@ func handleSelectorExpr(expr ast.Expr) string {
spew.Dump(s)
code += "unknown handleSelectorExpr"
}
code += "."
code += ".\\\n"
code += indSpacesPlus()
code += handleIdent(s.Sel)
if val, ok := mapping[code]; ok {
code = val

Просмотреть файл

@ -179,13 +179,23 @@ main()
import . "skidl"
func main() {
a.b.c = 1
a.b.c.d.e = 1
x = a.b.c.d.e
}
`
expected := `from skidl import *
def main():
a.b.c = 1
a.\
b.\
c.\
d.\
e = 1
x = a.\
b.\
c.\
d.\
e
main()
`
Compare(source, expected)
@ -248,7 +258,11 @@ main()
expected := `from skidl import *
def main():
a.b().c(1).d(2).e(3)
a.\
b().\
c(1).\
d(2).\
e(3)
main()
`
Compare(source, expected)
@ -476,10 +490,14 @@ main()
expected := `from skidl import *
def main():
vkl_iface.value = "k vkl"
vkl_iface.value = 19
vkl_iface.value = 19 / 3
vkl_iface.value = 19 * 2
vkl_iface.\
value = "k vkl"
vkl_iface.\
value = 19
vkl_iface.\
value = 19 / 3
vkl_iface.\
value = 19 * 2
main()
`
Compare(source, expected)
@ -701,9 +719,12 @@ main()
@subcircuit
def mem_module(intfc):
ram = Part("Memory_RAM","AS6C1616")
ram["A[0:19]"] += intfc.addr
ram["DQ[0:15]"] += intfc.data
ram["WE#"] += intfc.wr
ram["A[0:19]"] += intfc.\
addr
ram["DQ[0:15]"] += intfc.\
data
ram["WE#"] += intfc.\
wr
ram["OE#"] += intfc["rd"]
def main():
rd = Net("MEM_RD#")