@shd101wyy/yo 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/skills/yo-async-effects/SKILL.md +4 -4
- package/.github/skills/yo-async-effects/async-effects-recipes.md +34 -34
- package/.github/skills/yo-core-patterns/SKILL.md +1 -1
- package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +26 -26
- package/.github/skills/yo-project-workflow/SKILL.md +6 -3
- package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +34 -11
- package/.github/skills/yo-syntax/SKILL.md +7 -6
- package/.github/skills/yo-syntax/syntax-cheatsheet.md +73 -60
- package/.github/skills/yo-wasm-integration/wasm-integration-cheatsheet.md +3 -3
- package/README.md +10 -8
- package/out/cjs/index.cjs +456 -438
- package/out/cjs/yo-cli.cjs +576 -543
- package/out/cjs/yo-lsp.cjs +559 -532
- package/out/esm/index.mjs +281 -263
- package/out/types/src/formatter.d.ts +11 -0
- package/out/types/src/lsp/formatting.d.ts +2 -0
- package/out/types/src/tests/formatter.test.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/std/alg/hash.yo +13 -21
- package/std/allocator.yo +25 -40
- package/std/async.yo +3 -7
- package/std/build.yo +105 -151
- package/std/cli/arg_parser.yo +184 -169
- package/std/collections/array_list.yo +350 -314
- package/std/collections/btree_map.yo +142 -131
- package/std/collections/deque.yo +132 -128
- package/std/collections/hash_map.yo +542 -566
- package/std/collections/hash_set.yo +623 -687
- package/std/collections/linked_list.yo +275 -293
- package/std/collections/ordered_map.yo +113 -85
- package/std/collections/priority_queue.yo +73 -73
- package/std/crypto/md5.yo +191 -95
- package/std/crypto/random.yo +56 -64
- package/std/crypto/sha256.yo +151 -107
- package/std/encoding/base64.yo +87 -81
- package/std/encoding/hex.yo +43 -50
- package/std/encoding/html.yo +56 -81
- package/std/encoding/html_char_utils.yo +7 -13
- package/std/encoding/html_entities.yo +2248 -2253
- package/std/encoding/json.yo +316 -224
- package/std/encoding/punycode.yo +86 -116
- package/std/encoding/toml.yo +67 -66
- package/std/encoding/utf16.yo +37 -44
- package/std/env.yo +62 -91
- package/std/error.yo +7 -15
- package/std/fmt/display.yo +5 -9
- package/std/fmt/index.yo +8 -14
- package/std/fmt/to_string.yo +330 -315
- package/std/fmt/writer.yo +58 -87
- package/std/fs/dir.yo +83 -102
- package/std/fs/file.yo +147 -180
- package/std/fs/metadata.yo +45 -78
- package/std/fs/temp.yo +55 -65
- package/std/fs/types.yo +27 -40
- package/std/fs/walker.yo +53 -68
- package/std/gc.yo +5 -8
- package/std/glob.yo +30 -43
- package/std/http/client.yo +107 -120
- package/std/http/http.yo +106 -96
- package/std/http/index.yo +4 -6
- package/std/imm/list.yo +88 -93
- package/std/imm/map.yo +528 -464
- package/std/imm/set.yo +52 -57
- package/std/imm/sorted_map.yo +340 -286
- package/std/imm/sorted_set.yo +57 -63
- package/std/imm/string.yo +404 -345
- package/std/imm/vec.yo +173 -181
- package/std/io/reader.yo +3 -6
- package/std/io/writer.yo +4 -8
- package/std/libc/assert.yo +5 -9
- package/std/libc/ctype.yo +32 -22
- package/std/libc/dirent.yo +26 -25
- package/std/libc/errno.yo +164 -90
- package/std/libc/fcntl.yo +52 -45
- package/std/libc/float.yo +66 -44
- package/std/libc/limits.yo +42 -33
- package/std/libc/math.yo +53 -82
- package/std/libc/signal.yo +72 -47
- package/std/libc/stdatomic.yo +217 -188
- package/std/libc/stdint.yo +5 -29
- package/std/libc/stdio.yo +5 -29
- package/std/libc/stdlib.yo +32 -39
- package/std/libc/string.yo +5 -23
- package/std/libc/sys/stat.yo +58 -56
- package/std/libc/time.yo +5 -19
- package/std/libc/unistd.yo +5 -20
- package/std/libc/wctype.yo +6 -9
- package/std/libc/windows.yo +26 -30
- package/std/log.yo +41 -55
- package/std/net/addr.yo +102 -97
- package/std/net/dns.yo +27 -28
- package/std/net/errors.yo +50 -49
- package/std/net/tcp.yo +113 -124
- package/std/net/udp.yo +55 -66
- package/std/os/env.yo +35 -33
- package/std/os/signal.yo +15 -25
- package/std/path.yo +276 -311
- package/std/prelude.yo +6304 -4315
- package/std/process/command.yo +87 -103
- package/std/process/index.yo +12 -31
- package/std/regex/compiler.yo +196 -95
- package/std/regex/flags.yo +58 -39
- package/std/regex/index.yo +157 -173
- package/std/regex/match.yo +20 -31
- package/std/regex/node.yo +134 -152
- package/std/regex/parser.yo +283 -259
- package/std/regex/unicode.yo +172 -202
- package/std/regex/vm.yo +155 -171
- package/std/string/index.yo +5 -7
- package/std/string/rune.yo +45 -55
- package/std/string/string.yo +937 -964
- package/std/string/string_builder.yo +94 -104
- package/std/string/unicode.yo +46 -64
- package/std/sync/channel.yo +72 -73
- package/std/sync/cond.yo +31 -36
- package/std/sync/mutex.yo +30 -32
- package/std/sync/once.yo +13 -16
- package/std/sync/rwlock.yo +26 -31
- package/std/sync/waitgroup.yo +20 -25
- package/std/sys/advise.yo +16 -24
- package/std/sys/bufio/buf_reader.yo +77 -93
- package/std/sys/bufio/buf_writer.yo +52 -65
- package/std/sys/clock.yo +4 -9
- package/std/sys/constants.yo +77 -61
- package/std/sys/copy.yo +4 -10
- package/std/sys/dir.yo +26 -43
- package/std/sys/dns.yo +41 -61
- package/std/sys/errors.yo +95 -103
- package/std/sys/events.yo +45 -57
- package/std/sys/externs.yo +319 -267
- package/std/sys/fallocate.yo +7 -11
- package/std/sys/fcntl.yo +14 -22
- package/std/sys/file.yo +26 -40
- package/std/sys/future.yo +5 -8
- package/std/sys/iov.yo +12 -25
- package/std/sys/lock.yo +12 -13
- package/std/sys/mmap.yo +38 -43
- package/std/sys/path.yo +3 -8
- package/std/sys/perm.yo +7 -21
- package/std/sys/pipe.yo +5 -12
- package/std/sys/process.yo +23 -29
- package/std/sys/seek.yo +10 -12
- package/std/sys/signal.yo +7 -13
- package/std/sys/signals.yo +52 -35
- package/std/sys/socket.yo +63 -58
- package/std/sys/socketpair.yo +3 -6
- package/std/sys/sockinfo.yo +11 -20
- package/std/sys/statfs.yo +11 -34
- package/std/sys/statx.yo +25 -52
- package/std/sys/sysinfo.yo +15 -20
- package/std/sys/tcp.yo +62 -92
- package/std/sys/temp.yo +5 -9
- package/std/sys/time.yo +5 -15
- package/std/sys/timer.yo +6 -11
- package/std/sys/tty.yo +10 -18
- package/std/sys/udp.yo +22 -39
- package/std/sys/umask.yo +3 -6
- package/std/sys/unix.yo +33 -52
- package/std/testing/bench.yo +49 -52
- package/std/thread.yo +10 -15
- package/std/time/datetime.yo +105 -89
- package/std/time/duration.yo +43 -56
- package/std/time/instant.yo +13 -18
- package/std/time/sleep.yo +5 -9
- package/std/url/index.yo +184 -209
- package/std/worker.yo +6 -10
package/std/fs/walker.yo
CHANGED
|
@@ -21,134 +21,119 @@
|
|
|
21
21
|
//! };
|
|
22
22
|
//! });
|
|
23
23
|
//! ```
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
{
|
|
28
|
-
{
|
|
29
|
-
{
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
_dir :: import "./dir";
|
|
33
|
-
|
|
24
|
+
{ ArrayList } :: import("../collections/array_list");
|
|
25
|
+
open(import("../string"));
|
|
26
|
+
{ Path } :: import("../path");
|
|
27
|
+
{ IOError } :: import("../sys/errors");
|
|
28
|
+
{ Error, AnyError, Exception } :: import("../error");
|
|
29
|
+
{ FileType } :: import("./dir");
|
|
30
|
+
{ DirEntry } :: import("./dir");
|
|
31
|
+
_dir :: import("./dir");
|
|
34
32
|
/// Entry returned by the directory walker.
|
|
35
33
|
WalkEntry :: struct(
|
|
36
|
-
path
|
|
37
|
-
name
|
|
38
|
-
depth
|
|
34
|
+
path : Path,
|
|
35
|
+
name : String,
|
|
36
|
+
depth : u32,
|
|
39
37
|
file_type : FileType
|
|
40
38
|
);
|
|
41
|
-
|
|
42
|
-
export WalkEntry;
|
|
43
|
-
|
|
39
|
+
export(WalkEntry);
|
|
44
40
|
/// Options controlling directory walk behavior.
|
|
45
41
|
WalkOptions :: struct(
|
|
46
|
-
max_depth
|
|
42
|
+
max_depth : ?(u32),
|
|
47
43
|
follow_symlinks : bool,
|
|
48
|
-
include_dirs
|
|
44
|
+
include_dirs : bool
|
|
49
45
|
);
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
impl(
|
|
47
|
+
WalkOptions,
|
|
52
48
|
defaults : (fn() -> Self)(
|
|
53
49
|
Self(
|
|
54
|
-
max_depth
|
|
55
|
-
follow_symlinks: false,
|
|
56
|
-
include_dirs: true
|
|
50
|
+
max_depth :.None,
|
|
51
|
+
follow_symlinks : false,
|
|
52
|
+
include_dirs : true
|
|
57
53
|
)
|
|
58
54
|
)
|
|
59
55
|
);
|
|
60
|
-
|
|
61
|
-
export WalkOptions;
|
|
62
|
-
|
|
56
|
+
export(WalkOptions);
|
|
63
57
|
// ============================================================================
|
|
64
58
|
// Internal path join helper
|
|
65
59
|
// ============================================================================
|
|
66
|
-
|
|
67
|
-
_join_path :: (fn(base: String, name: String) -> String)(
|
|
60
|
+
_join_path :: (fn(base : String, name : String) -> String)(
|
|
68
61
|
cond(
|
|
69
62
|
base.ends_with(String.from("/")) => `${base}${name}`,
|
|
70
63
|
true => `${base}/${name}`
|
|
71
64
|
)
|
|
72
65
|
);
|
|
73
|
-
|
|
74
66
|
// ============================================================================
|
|
75
67
|
// Walk functions
|
|
76
68
|
// ============================================================================
|
|
77
|
-
|
|
78
69
|
// Walk a directory tree with custom options.
|
|
79
|
-
walk_with :: (fn(root: Path, options: WalkOptions, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))({
|
|
70
|
+
walk_with :: (fn(root : Path, options : WalkOptions, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))({
|
|
80
71
|
root_s := root.to_string();
|
|
81
72
|
io.async((using(io, exn)) => {
|
|
82
73
|
results := ArrayList(WalkEntry).new();
|
|
83
74
|
// Stack of (path, depth) pairs to process
|
|
84
|
-
stack := ArrayList(struct(path: String, depth: u32)).new();
|
|
85
|
-
stack.push({ path: root_s, depth: u32(0) });
|
|
86
|
-
|
|
87
|
-
while runtime((stack.len() > usize(0))), {
|
|
75
|
+
stack := ArrayList(struct(path : String, depth : u32)).new();
|
|
76
|
+
stack.push({ path : root_s, depth : u32(0) });
|
|
77
|
+
while(runtime(stack.len() > usize(0)), {
|
|
88
78
|
item := stack.pop().unwrap();
|
|
89
79
|
cur_path := item.path;
|
|
90
80
|
cur_depth := item.depth;
|
|
91
|
-
|
|
92
81
|
// Check max depth
|
|
93
|
-
should_continue := match(
|
|
82
|
+
should_continue := match(
|
|
83
|
+
options.max_depth,
|
|
94
84
|
.Some(max) => (cur_depth <= max),
|
|
95
85
|
.None => true
|
|
96
86
|
);
|
|
97
|
-
|
|
98
87
|
cond(
|
|
99
88
|
should_continue => {
|
|
100
89
|
entries := io.await(_dir.read_dir(Path.new(cur_path)));
|
|
101
90
|
i := usize(0);
|
|
102
|
-
while
|
|
91
|
+
while(runtime(i < entries.len()), {
|
|
103
92
|
entry := entries.get(i).unwrap();
|
|
104
93
|
entry_path := _join_path(cur_path, entry.name);
|
|
105
|
-
match(
|
|
94
|
+
match(
|
|
95
|
+
entry.file_type,
|
|
106
96
|
.Directory => {
|
|
107
97
|
cond(
|
|
108
98
|
options.include_dirs => {
|
|
109
|
-
results.push(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
99
|
+
results.push(
|
|
100
|
+
WalkEntry(
|
|
101
|
+
path : Path.new(entry_path),
|
|
102
|
+
name : entry.name,
|
|
103
|
+
depth : cur_depth,
|
|
104
|
+
file_type :.Directory
|
|
105
|
+
)
|
|
106
|
+
);
|
|
115
107
|
},
|
|
116
108
|
true => ()
|
|
117
109
|
);
|
|
118
110
|
// Push subdirectory for processing
|
|
119
|
-
stack.push({ path: entry_path, depth: (cur_depth + u32(1)) });
|
|
111
|
+
stack.push({ path : entry_path, depth : (cur_depth + u32(1)) });
|
|
120
112
|
},
|
|
121
113
|
_ => {
|
|
122
|
-
results.push(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
114
|
+
results.push(
|
|
115
|
+
WalkEntry(
|
|
116
|
+
path : Path.new(entry_path),
|
|
117
|
+
name : entry.name,
|
|
118
|
+
depth : cur_depth,
|
|
119
|
+
file_type : entry.file_type
|
|
120
|
+
)
|
|
121
|
+
);
|
|
128
122
|
}
|
|
129
123
|
);
|
|
130
124
|
i = (i + usize(1));
|
|
131
|
-
};
|
|
125
|
+
});
|
|
132
126
|
},
|
|
133
127
|
true => ()
|
|
134
128
|
);
|
|
135
|
-
};
|
|
136
|
-
|
|
129
|
+
});
|
|
137
130
|
results
|
|
138
131
|
})
|
|
139
132
|
});
|
|
140
|
-
|
|
141
|
-
walk_with_cstr :: (fn(root: *(u8), options: WalkOptions, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))(
|
|
133
|
+
walk_with_cstr :: (fn(root : *(u8), options : WalkOptions, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))(
|
|
142
134
|
walk_with(Path.from_cstr(root), options)
|
|
143
135
|
);
|
|
144
|
-
|
|
145
136
|
/// Walk a directory tree with default options.
|
|
146
|
-
walk :: (fn(root: Path, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))
|
|
147
|
-
|
|
148
|
-
;
|
|
149
|
-
|
|
150
|
-
walk_cstr :: (fn(root: *(u8), using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))
|
|
151
|
-
walk(Path.from_cstr(root))
|
|
152
|
-
;
|
|
153
|
-
|
|
154
|
-
export walk, walk_cstr, walk_with, walk_with_cstr;
|
|
137
|
+
walk :: (fn(root : Path, using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))(walk_with(root, WalkOptions.defaults()));
|
|
138
|
+
walk_cstr :: (fn(root : *(u8), using(io : IO)) -> Impl(Future(ArrayList(WalkEntry), IO, Exception)))(walk(Path.from_cstr(root)));
|
|
139
|
+
export(walk, walk_cstr, walk_with, walk_with_cstr);
|
package/std/gc.yo
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
//! Garbage collection interface for cycle collection.
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
extern(
|
|
3
|
+
"Yo",
|
|
4
4
|
__yo_gc_collect : (fn() -> unit),
|
|
5
5
|
__yo_gc_tracked_count : (fn() -> u64)
|
|
6
|
-
;
|
|
7
|
-
|
|
6
|
+
);
|
|
8
7
|
/// Trigger the cycle collector to reclaim reference cycles.
|
|
9
8
|
collect :: __yo_gc_collect;
|
|
10
|
-
|
|
11
9
|
/// Get the number of objects currently tracked by the cycle collector.
|
|
12
10
|
tracked_count :: __yo_gc_tracked_count;
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
export tracked_count;
|
|
11
|
+
export(collect);
|
|
12
|
+
export(tracked_count);
|
package/std/glob.yo
CHANGED
|
@@ -1,33 +1,28 @@
|
|
|
1
1
|
//! Glob pattern matching for file paths.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
{ ArrayList } :: import "./collections/array_list";
|
|
5
|
-
|
|
2
|
+
open(import("./string"));
|
|
3
|
+
{ ArrayList } :: import("./collections/array_list");
|
|
6
4
|
// Recursive byte-level glob pattern matching
|
|
7
|
-
_glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usize) -> bool)({
|
|
5
|
+
_glob_match_impl :: (fn(pb : ArrayList(u8), pi : usize, tb : ArrayList(u8), ti : usize) -> bool)({
|
|
8
6
|
// Base: both pattern and text consumed
|
|
9
7
|
cond(
|
|
10
8
|
((pi == pb.len()) && (ti == tb.len())) => {
|
|
11
|
-
return
|
|
9
|
+
return(true);
|
|
12
10
|
},
|
|
13
11
|
true => ()
|
|
14
12
|
);
|
|
15
|
-
|
|
16
13
|
// Pattern consumed but text remains
|
|
17
14
|
cond(
|
|
18
15
|
(pi == pb.len()) => {
|
|
19
|
-
return
|
|
16
|
+
return(false);
|
|
20
17
|
},
|
|
21
18
|
true => ()
|
|
22
19
|
);
|
|
23
|
-
|
|
24
20
|
p := pb.get(pi).unwrap();
|
|
25
|
-
|
|
26
21
|
// Handle * and **
|
|
27
22
|
cond(
|
|
28
23
|
(p == u8(42)) => {
|
|
29
24
|
is_dbl := cond(
|
|
30
|
-
((pi + usize(1)) < pb.len()) => (pb.get(
|
|
25
|
+
((pi + usize(1)) < pb.len()) => (pb.get(pi + usize(1)).unwrap() == u8(42)),
|
|
31
26
|
true => false
|
|
32
27
|
);
|
|
33
28
|
cond(
|
|
@@ -49,17 +44,17 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
|
|
|
49
44
|
// Try ** matching nothing
|
|
50
45
|
cond(
|
|
51
46
|
recur(pb, npi, tb, ti) => {
|
|
52
|
-
return
|
|
47
|
+
return(true);
|
|
53
48
|
},
|
|
54
49
|
true => ()
|
|
55
50
|
);
|
|
56
51
|
// Try ** consuming one char
|
|
57
52
|
cond(
|
|
58
53
|
(ti < tb.len()) => {
|
|
59
|
-
return
|
|
54
|
+
return(recur(pb, pi, tb, ti + usize(1)));
|
|
60
55
|
},
|
|
61
56
|
true => {
|
|
62
|
-
return
|
|
57
|
+
return(false);
|
|
63
58
|
}
|
|
64
59
|
);
|
|
65
60
|
},
|
|
@@ -67,8 +62,8 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
|
|
|
67
62
|
// Single * matches any except /
|
|
68
63
|
// Try * matching nothing
|
|
69
64
|
cond(
|
|
70
|
-
recur(pb,
|
|
71
|
-
return
|
|
65
|
+
recur(pb, pi + usize(1), tb, ti) => {
|
|
66
|
+
return(true);
|
|
72
67
|
},
|
|
73
68
|
true => ()
|
|
74
69
|
);
|
|
@@ -78,15 +73,15 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
|
|
|
78
73
|
tc := tb.get(ti).unwrap();
|
|
79
74
|
cond(
|
|
80
75
|
(tc != u8(47)) => {
|
|
81
|
-
return
|
|
76
|
+
return(recur(pb, pi, tb, ti + usize(1)));
|
|
82
77
|
},
|
|
83
78
|
true => {
|
|
84
|
-
return
|
|
79
|
+
return(false);
|
|
85
80
|
}
|
|
86
81
|
);
|
|
87
82
|
},
|
|
88
83
|
true => {
|
|
89
|
-
return
|
|
84
|
+
return(false);
|
|
90
85
|
}
|
|
91
86
|
);
|
|
92
87
|
}
|
|
@@ -94,32 +89,28 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
|
|
|
94
89
|
},
|
|
95
90
|
true => ()
|
|
96
91
|
);
|
|
97
|
-
|
|
98
92
|
// Text consumed but non-star pattern remains
|
|
99
93
|
cond(
|
|
100
94
|
(ti == tb.len()) => {
|
|
101
|
-
return
|
|
95
|
+
return(false);
|
|
102
96
|
},
|
|
103
97
|
true => ()
|
|
104
98
|
);
|
|
105
|
-
|
|
106
99
|
t := tb.get(ti).unwrap();
|
|
107
|
-
|
|
108
100
|
// Handle ?
|
|
109
101
|
cond(
|
|
110
102
|
(p == u8(63)) => {
|
|
111
103
|
cond(
|
|
112
104
|
(t != u8(47)) => {
|
|
113
|
-
return
|
|
105
|
+
return(recur(pb, pi + usize(1), tb, ti + usize(1)));
|
|
114
106
|
},
|
|
115
107
|
true => {
|
|
116
|
-
return
|
|
108
|
+
return(false);
|
|
117
109
|
}
|
|
118
110
|
);
|
|
119
111
|
},
|
|
120
112
|
true => ()
|
|
121
113
|
);
|
|
122
|
-
|
|
123
114
|
// Handle [...]
|
|
124
115
|
cond(
|
|
125
116
|
(p == u8(91)) => {
|
|
@@ -142,7 +133,7 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
|
|
|
142
133
|
// Scan characters in class until ]
|
|
143
134
|
found := false;
|
|
144
135
|
cdone := false;
|
|
145
|
-
while
|
|
136
|
+
while((ci < pb.len()) && (!(cdone)), ci = (ci + usize(1)), {
|
|
146
137
|
ch := pb.get(ci).unwrap();
|
|
147
138
|
cond(
|
|
148
139
|
(ch == u8(93)) => {
|
|
@@ -157,11 +148,11 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
|
|
|
157
148
|
);
|
|
158
149
|
}
|
|
159
150
|
);
|
|
160
|
-
};
|
|
151
|
+
});
|
|
161
152
|
// Malformed pattern (no closing ])
|
|
162
153
|
cond(
|
|
163
154
|
(!(cdone)) => {
|
|
164
|
-
return
|
|
155
|
+
return(false);
|
|
165
156
|
},
|
|
166
157
|
true => ()
|
|
167
158
|
);
|
|
@@ -171,39 +162,35 @@ _glob_match_impl :: (fn(pb: ArrayList(u8), pi: usize, tb: ArrayList(u8), ti: usi
|
|
|
171
162
|
);
|
|
172
163
|
cond(
|
|
173
164
|
matched => {
|
|
174
|
-
return
|
|
165
|
+
return(recur(pb, ci, tb, ti + usize(1)));
|
|
175
166
|
},
|
|
176
167
|
true => {
|
|
177
|
-
return
|
|
168
|
+
return(false);
|
|
178
169
|
}
|
|
179
170
|
);
|
|
180
171
|
},
|
|
181
172
|
true => ()
|
|
182
173
|
);
|
|
183
|
-
|
|
184
174
|
// Literal byte match
|
|
185
175
|
cond(
|
|
186
|
-
(p == t) => recur(pb,
|
|
176
|
+
(p == t) => recur(pb, pi + usize(1), tb, ti + usize(1)),
|
|
187
177
|
true => false
|
|
188
178
|
)
|
|
189
179
|
});
|
|
190
|
-
|
|
191
|
-
glob_match :: (fn(pattern: String, text: String) -> bool)(
|
|
180
|
+
glob_match :: (fn(pattern : String, text : String) -> bool)(
|
|
192
181
|
_glob_match_impl(pattern.as_bytes(), usize(0), text.as_bytes(), usize(0))
|
|
193
182
|
);
|
|
194
|
-
|
|
195
183
|
/// Compiled glob pattern that can be matched against strings.
|
|
196
184
|
GlobPattern :: object(
|
|
197
185
|
_pattern : String
|
|
198
186
|
);
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
new : (fn(pattern: String) -> Self)(
|
|
202
|
-
Self(_pattern: pattern)
|
|
187
|
+
impl(
|
|
188
|
+
GlobPattern,
|
|
189
|
+
new : (fn(pattern : String) -> Self)(
|
|
190
|
+
Self(_pattern : pattern)
|
|
203
191
|
),
|
|
204
|
-
matches : (fn(self: Self, text: String) -> bool)(
|
|
192
|
+
matches : (fn(self : Self, text : String) -> bool)(
|
|
205
193
|
_glob_match_impl(self._pattern.as_bytes(), usize(0), text.as_bytes(), usize(0))
|
|
206
194
|
)
|
|
207
195
|
);
|
|
208
|
-
|
|
209
|
-
export glob_match, GlobPattern;
|
|
196
|
+
export(glob_match, GlobPattern);
|