v0.3.3: is lib word, UTF–8 string support

This commit is contained in:
Luxferre
2026-07-07 08:27:15 +03:00
parent 6ccd7e7350
commit 07e9fe4651
2 changed files with 1 additions and 19 deletions
-16
View File
@@ -533,19 +533,3 @@ func NewClyx(libfname string, libCode string) *Clyx {
} }
return c return c
} }
func RunFile(filePath string, libCode string) {
content, err := os.ReadFile(filePath)
if err != nil {
fmt.Fprintf(os.Stderr, "Error executing %s: %v\n", filePath, err)
os.Exit(1)
}
defer func() {
if r := recover(); r != nil { fmt.Fprintf(os.Stderr, "Error executing %s: %v\n", filePath, r); os.Exit(1) }
}()
c := NewClyx("", libCode)
c.Run(string(content))
if c.HasWord("_main") {
c.Run("_main")
}
}
+1 -3
View File
@@ -19,12 +19,10 @@ replpath = _fpath(f'{scriptdir}/clyx_repl.clx', f'{scriptdir}/../../clyx_repl.cl
class Sock: class Sock:
def __init__(self, s): self.s = s def __init__(self, s): self.s = s
def write(self, d):
data = d.encode('utf-8') if isinstance(d, str) else d
return self.s.write(data) if hasattr(self.s, 'write') else self.send(data)
def send(self, d): def send(self, d):
data = d.encode('utf-8') if isinstance(d, str) else d data = d.encode('utf-8') if isinstance(d, str) else d
return self.s.send(data) if hasattr(self.s, 'send') else getattr(self.s, 'write', lambda *a: 0)(data) return self.s.send(data) if hasattr(self.s, 'send') else getattr(self.s, 'write', lambda *a: 0)(data)
def write(self, d): return self.send(d)
def recv(self, n): def recv(self, n):
b = bytearray(n); return bytes(b[:self.s.recv_into(b)]) if hasattr(self.s, 'recv_into') else getattr(self.s, 'read', lambda *a: b'')(n) b = bytearray(n); return bytes(b[:self.s.recv_into(b)]) if hasattr(self.s, 'recv_into') else getattr(self.s, 'read', lambda *a: b'')(n)
def readline(self): def readline(self):