From 5d39c17e1e08ab2f5f9451af326436ee5b5a8df5 Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Sun, 10 Sep 2023 03:23:42 +0900 Subject: [PATCH] feat: add `shlex`/`pickle`/`marshal` --- crates/erg_compiler/lib/pystd/marshal.d.er | 6 ++++++ crates/erg_compiler/lib/pystd/pickle.d.er | 17 +++++++++++++++++ crates/erg_compiler/lib/pystd/shlex.d.er | 18 ++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 crates/erg_compiler/lib/pystd/marshal.d.er create mode 100644 crates/erg_compiler/lib/pystd/pickle.d.er create mode 100644 crates/erg_compiler/lib/pystd/shlex.d.er diff --git a/crates/erg_compiler/lib/pystd/marshal.d.er b/crates/erg_compiler/lib/pystd/marshal.d.er new file mode 100644 index 000000000..15f722279 --- /dev/null +++ b/crates/erg_compiler/lib/pystd/marshal.d.er @@ -0,0 +1,6 @@ +.version: Nat + +.dump!: (value: Obj, file := PathLike, version := Nat) => NoneType +.load!: (file: PathLike) => Obj +.dumps: (value: Obj, version := Nat) -> Bytes +.loads: (bytes: Bytes) -> Obj diff --git a/crates/erg_compiler/lib/pystd/pickle.d.er b/crates/erg_compiler/lib/pystd/pickle.d.er new file mode 100644 index 000000000..fc82e1a15 --- /dev/null +++ b/crates/erg_compiler/lib/pystd/pickle.d.er @@ -0,0 +1,17 @@ +.HIGHEST_PROTOCOL: Nat +.DEFAULT_PROTOCOL: Nat + +.dump!: (obj: Obj, file: PathLike, protocol := Nat) => NoneType +.dumps: (obj: Obj, protocol := Nat) -> Bytes +.load!: ( + file: PathLike, + fix_imports := Bool, + encoding := Str, + errors := Str, +) => Obj +.loads: ( + data: Bytes, + fix_imports := Bool, + encoding := Str, + errors := Str +) -> Obj diff --git a/crates/erg_compiler/lib/pystd/shlex.d.er b/crates/erg_compiler/lib/pystd/shlex.d.er new file mode 100644 index 000000000..d97a5eeff --- /dev/null +++ b/crates/erg_compiler/lib/pystd/shlex.d.er @@ -0,0 +1,18 @@ +.Shlex! = 'shlex': ClassType +.Shlex!. + commenters: Str + wordchars: Str + whitespace: Str + escape: Str + quotes: Str + escapedquotes: Str + whitespace_split: Bool + infile: Str + __call__: (instream := Str, posix := Bool, punctuation_chars := Bool) -> .Shlex! + get_token!: (self: RefMut(.Shlex!)) => Str + push_token!: (self: RefMut(.Shlex!), token: Str) => NoneType + read_token!: (self: RefMut(.Shlex!)) => Str + +.split: (s: Str, comments := Bool, posix := Bool) -> [Str; _] +.join: (split_command: Iterable(Str)) -> Str +.quote: (s: Str) -> Str