@shd101wyy/yo 0.1.25 → 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 +40 -40
- package/.github/skills/yo-core-patterns/SKILL.md +1 -1
- package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +30 -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 +78 -60
- package/.github/skills/yo-wasm-integration/wasm-integration-cheatsheet.md +3 -3
- package/README.md +10 -8
- package/out/cjs/index.cjs +583 -567
- package/out/cjs/yo-cli.cjs +664 -632
- package/out/cjs/yo-lsp.cjs +510 -485
- package/out/esm/index.mjs +538 -522
- package/out/types/src/codegen/codegen-c.d.ts +2 -2
- package/out/types/src/codegen/functions/collection.d.ts +2 -2
- package/out/types/src/codegen/functions/context.d.ts +3 -2
- package/out/types/src/codegen/types/collection.d.ts +2 -2
- package/out/types/src/codegen/utils/index.d.ts +3 -1
- package/out/types/src/doc/builder.d.ts +2 -2
- package/out/types/src/evaluator/calls/closure-type.d.ts +2 -2
- package/out/types/src/evaluator/calls/record-type.d.ts +11 -0
- package/out/types/src/evaluator/context.d.ts +8 -9
- package/out/types/src/evaluator/index.d.ts +3 -3
- package/out/types/src/evaluator/types/record.d.ts +14 -0
- package/out/types/src/evaluator/types/validation.d.ts +2 -2
- package/out/types/src/evaluator/values/anonymous-module.d.ts +5 -5
- package/out/types/src/evaluator/values/impl.d.ts +1 -1
- package/out/types/src/expr.d.ts +1 -4
- package/out/types/src/formatter.d.ts +11 -0
- package/out/types/src/function-value.d.ts +1 -1
- package/out/types/src/lsp/document-manager.d.ts +1 -1
- package/out/types/src/lsp/formatting.d.ts +2 -0
- package/out/types/src/module-manager.d.ts +3 -3
- package/out/types/src/tests/formatter.test.d.ts +1 -0
- package/out/types/src/types/creators.d.ts +3 -4
- package/out/types/src/types/definitions.d.ts +8 -19
- package/out/types/src/types/guards.d.ts +3 -3
- package/out/types/src/types/tags.d.ts +0 -1
- package/out/types/src/types/utils.d.ts +1 -1
- package/out/types/src/value-tag.d.ts +0 -1
- package/out/types/src/value.d.ts +6 -13
- 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 +12 -20
- 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 +6316 -4333
- 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/out/types/src/evaluator/calls/module-type.d.ts +0 -11
- package/out/types/src/evaluator/types/module.d.ts +0 -19
package/std/regex/match.yo
CHANGED
|
@@ -1,81 +1,70 @@
|
|
|
1
1
|
//! Match result type — represents the result of a regex match,
|
|
2
2
|
//! including the matched text, position, and captured groups.
|
|
3
|
-
|
|
4
|
-
open
|
|
5
|
-
|
|
6
|
-
{ GroupNameEntry } :: import "./node.yo";
|
|
7
|
-
|
|
3
|
+
open(import("std/collections/array_list"));
|
|
4
|
+
open(import("std/string"));
|
|
5
|
+
{ GroupNameEntry } :: import("./node.yo");
|
|
8
6
|
/// A single regex match result.
|
|
9
7
|
RegexMatch :: object(
|
|
10
|
-
_value
|
|
11
|
-
_index
|
|
12
|
-
_input
|
|
13
|
-
_groups
|
|
8
|
+
_value : String,
|
|
9
|
+
_index : usize,
|
|
10
|
+
_input : String,
|
|
11
|
+
_groups : ArrayList(Option(String)),
|
|
14
12
|
_group_names : ArrayList(GroupNameEntry)
|
|
15
13
|
);
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
impl(
|
|
15
|
+
RegexMatch,
|
|
18
16
|
// Create a match result
|
|
19
17
|
new : (fn(value : String, index : usize, input : String, groups : ArrayList(Option(String)), group_names : ArrayList(GroupNameEntry)) -> Self)(
|
|
20
18
|
Self(
|
|
21
|
-
_value: value,
|
|
22
|
-
_index: index,
|
|
23
|
-
_input: input,
|
|
24
|
-
_groups: groups,
|
|
25
|
-
_group_names: group_names
|
|
19
|
+
_value : value,
|
|
20
|
+
_index : index,
|
|
21
|
+
_input : input,
|
|
22
|
+
_groups : groups,
|
|
23
|
+
_group_names : group_names
|
|
26
24
|
)
|
|
27
25
|
),
|
|
28
|
-
|
|
29
26
|
// Get the full matched text
|
|
30
27
|
value : (fn(self : Self) -> String)(
|
|
31
28
|
self._value
|
|
32
29
|
),
|
|
33
|
-
|
|
34
30
|
// Get the start position (character index) of the match
|
|
35
31
|
index : (fn(self : Self) -> usize)(
|
|
36
32
|
self._index
|
|
37
33
|
),
|
|
38
|
-
|
|
39
34
|
// Get the original input string
|
|
40
35
|
input : (fn(self : Self) -> String)(
|
|
41
36
|
self._input
|
|
42
37
|
),
|
|
43
|
-
|
|
44
38
|
// Get capture group by index (1-based, group 0 is the full match)
|
|
45
39
|
group : (fn(self : Self, idx : usize) -> Option(String))(
|
|
46
40
|
cond(
|
|
47
|
-
(idx == usize(0))
|
|
41
|
+
(idx == usize(0)) =>.Some(self._value),
|
|
48
42
|
true => {
|
|
49
43
|
actual_idx := (idx - usize(1));
|
|
50
44
|
cond(
|
|
51
45
|
(actual_idx < self._groups.len()) => self._groups.get(actual_idx).unwrap(),
|
|
52
|
-
true
|
|
46
|
+
true =>.None
|
|
53
47
|
)
|
|
54
48
|
}
|
|
55
49
|
)
|
|
56
50
|
),
|
|
57
|
-
|
|
58
51
|
// Get capture group by name
|
|
59
52
|
named_group : (fn(self : Self, name : String) -> Option(String))({
|
|
60
53
|
i := usize(0);
|
|
61
|
-
while
|
|
54
|
+
while(i < self._group_names.len(), i = (i + usize(1)), {
|
|
62
55
|
entry := self._group_names.get(i).unwrap();
|
|
63
56
|
cond(
|
|
64
57
|
(entry.name == name) => {
|
|
65
|
-
return
|
|
58
|
+
return(self.group(entry.index));
|
|
66
59
|
},
|
|
67
60
|
true => ()
|
|
68
61
|
);
|
|
69
|
-
};
|
|
62
|
+
});
|
|
70
63
|
.None
|
|
71
64
|
}),
|
|
72
|
-
|
|
73
65
|
// Get number of capture groups (not counting group 0)
|
|
74
66
|
group_count : (fn(self : Self) -> usize)(
|
|
75
67
|
self._groups.len()
|
|
76
68
|
)
|
|
77
69
|
);
|
|
78
|
-
|
|
79
|
-
export
|
|
80
|
-
RegexMatch
|
|
81
|
-
;
|
|
70
|
+
export(RegexMatch);
|
package/std/regex/node.yo
CHANGED
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
//! The parser produces a tree of `RegexNode` objects representing the
|
|
4
4
|
//! structure of a regex pattern. Nodes are reference-counted objects
|
|
5
5
|
//! since they form a recursive tree.
|
|
6
|
-
|
|
7
|
-
open
|
|
8
|
-
open import "std/string";
|
|
9
|
-
|
|
6
|
+
open(import("std/collections/array_list"));
|
|
7
|
+
open(import("std/string"));
|
|
10
8
|
/// A range of characters for character classes, e.g. `a`–`z`.
|
|
11
9
|
CharRange :: struct(
|
|
12
|
-
low
|
|
10
|
+
low : u32,
|
|
13
11
|
high : u32
|
|
14
12
|
);
|
|
15
|
-
|
|
16
13
|
// Anchor types for ^ $ \b \B
|
|
17
14
|
AnchorKind :: enum(
|
|
18
15
|
Start,
|
|
@@ -20,7 +17,6 @@ AnchorKind :: enum(
|
|
|
20
17
|
WordBoundary,
|
|
21
18
|
NonWordBoundary
|
|
22
19
|
);
|
|
23
|
-
|
|
24
20
|
// Node kind tag
|
|
25
21
|
NodeKind :: enum(
|
|
26
22
|
Literal,
|
|
@@ -36,248 +32,234 @@ NodeKind :: enum(
|
|
|
36
32
|
Lookahead,
|
|
37
33
|
Lookbehind
|
|
38
34
|
);
|
|
39
|
-
|
|
40
35
|
// Entry mapping a named group to its index
|
|
41
36
|
GroupNameEntry :: struct(
|
|
42
|
-
name
|
|
37
|
+
name : String,
|
|
43
38
|
index : usize
|
|
44
39
|
);
|
|
45
|
-
|
|
46
40
|
// The regex AST node type.
|
|
47
41
|
// Uses `object(...)` for reference counting since nodes are recursive.
|
|
48
42
|
// Self-reference via `Self` (like LinkedList's Node).
|
|
49
43
|
RegexNode :: object(
|
|
50
|
-
kind
|
|
44
|
+
kind : NodeKind,
|
|
51
45
|
children : ArrayList(Self),
|
|
52
46
|
// For Literal nodes: the codepoint
|
|
53
47
|
codepoint : u32,
|
|
54
48
|
// For CharClass nodes: ranges and negation flag
|
|
55
|
-
ranges
|
|
56
|
-
negated
|
|
49
|
+
ranges : ArrayList(CharRange),
|
|
50
|
+
negated : bool,
|
|
57
51
|
// For Quantifier nodes: min, max, greedy
|
|
58
|
-
q_min
|
|
59
|
-
q_max
|
|
52
|
+
q_min : usize,
|
|
53
|
+
q_max : usize,
|
|
60
54
|
q_greedy : bool,
|
|
61
55
|
// For Group/Save nodes: group index
|
|
62
56
|
group_index : usize,
|
|
63
57
|
// For Anchor nodes
|
|
64
|
-
anchor
|
|
58
|
+
anchor : AnchorKind
|
|
65
59
|
);
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
impl(
|
|
61
|
+
RegexNode,
|
|
68
62
|
// Create a literal node matching a single codepoint
|
|
69
63
|
literal : (fn(cp : u32) -> Self)(
|
|
70
64
|
Self(
|
|
71
|
-
kind
|
|
72
|
-
children: ArrayList(RegexNode).new(),
|
|
73
|
-
codepoint: cp,
|
|
74
|
-
ranges: ArrayList(CharRange).new(),
|
|
75
|
-
negated: false,
|
|
76
|
-
q_min: usize(0),
|
|
77
|
-
q_max: usize(0),
|
|
78
|
-
q_greedy: true,
|
|
79
|
-
group_index: usize(0),
|
|
80
|
-
anchor
|
|
65
|
+
kind :.Literal,
|
|
66
|
+
children : ArrayList(RegexNode).new(),
|
|
67
|
+
codepoint : cp,
|
|
68
|
+
ranges : ArrayList(CharRange).new(),
|
|
69
|
+
negated : false,
|
|
70
|
+
q_min : usize(0),
|
|
71
|
+
q_max : usize(0),
|
|
72
|
+
q_greedy : true,
|
|
73
|
+
group_index : usize(0),
|
|
74
|
+
anchor :.Start
|
|
81
75
|
)
|
|
82
76
|
),
|
|
83
|
-
|
|
84
77
|
// Create a dot (any char) node
|
|
85
78
|
dot : (fn() -> Self)(
|
|
86
79
|
Self(
|
|
87
|
-
kind
|
|
88
|
-
children: ArrayList(RegexNode).new(),
|
|
89
|
-
codepoint: u32(0),
|
|
90
|
-
ranges: ArrayList(CharRange).new(),
|
|
91
|
-
negated: false,
|
|
92
|
-
q_min: usize(0),
|
|
93
|
-
q_max: usize(0),
|
|
94
|
-
q_greedy: true,
|
|
95
|
-
group_index: usize(0),
|
|
96
|
-
anchor
|
|
80
|
+
kind :.Dot,
|
|
81
|
+
children : ArrayList(RegexNode).new(),
|
|
82
|
+
codepoint : u32(0),
|
|
83
|
+
ranges : ArrayList(CharRange).new(),
|
|
84
|
+
negated : false,
|
|
85
|
+
q_min : usize(0),
|
|
86
|
+
q_max : usize(0),
|
|
87
|
+
q_greedy : true,
|
|
88
|
+
group_index : usize(0),
|
|
89
|
+
anchor :.Start
|
|
97
90
|
)
|
|
98
91
|
),
|
|
99
|
-
|
|
100
92
|
// Create a character class node
|
|
101
93
|
char_class : (fn(ranges : ArrayList(CharRange), negated : bool) -> Self)(
|
|
102
94
|
Self(
|
|
103
|
-
kind
|
|
104
|
-
children: ArrayList(RegexNode).new(),
|
|
105
|
-
codepoint: u32(0),
|
|
106
|
-
ranges: ranges,
|
|
107
|
-
negated: negated,
|
|
108
|
-
q_min: usize(0),
|
|
109
|
-
q_max: usize(0),
|
|
110
|
-
q_greedy: true,
|
|
111
|
-
group_index: usize(0),
|
|
112
|
-
anchor
|
|
95
|
+
kind :.CharClass,
|
|
96
|
+
children : ArrayList(RegexNode).new(),
|
|
97
|
+
codepoint : u32(0),
|
|
98
|
+
ranges : ranges,
|
|
99
|
+
negated : negated,
|
|
100
|
+
q_min : usize(0),
|
|
101
|
+
q_max : usize(0),
|
|
102
|
+
q_greedy : true,
|
|
103
|
+
group_index : usize(0),
|
|
104
|
+
anchor :.Start
|
|
113
105
|
)
|
|
114
106
|
),
|
|
115
|
-
|
|
116
107
|
// Create an anchor node (^, $, \b, \B)
|
|
117
108
|
anchor_node : (fn(kind : AnchorKind) -> Self)(
|
|
118
109
|
Self(
|
|
119
|
-
kind
|
|
120
|
-
children: ArrayList(RegexNode).new(),
|
|
121
|
-
codepoint: u32(0),
|
|
122
|
-
ranges: ArrayList(CharRange).new(),
|
|
123
|
-
negated: false,
|
|
124
|
-
q_min: usize(0),
|
|
125
|
-
q_max: usize(0),
|
|
126
|
-
q_greedy: true,
|
|
127
|
-
group_index: usize(0),
|
|
128
|
-
anchor: kind
|
|
110
|
+
kind :.Anchor,
|
|
111
|
+
children : ArrayList(RegexNode).new(),
|
|
112
|
+
codepoint : u32(0),
|
|
113
|
+
ranges : ArrayList(CharRange).new(),
|
|
114
|
+
negated : false,
|
|
115
|
+
q_min : usize(0),
|
|
116
|
+
q_max : usize(0),
|
|
117
|
+
q_greedy : true,
|
|
118
|
+
group_index : usize(0),
|
|
119
|
+
anchor : kind
|
|
129
120
|
)
|
|
130
121
|
),
|
|
131
|
-
|
|
132
122
|
// Create a sequence node (concatenation of children)
|
|
133
123
|
sequence : (fn(nodes : ArrayList(RegexNode)) -> Self)(
|
|
134
124
|
Self(
|
|
135
|
-
kind
|
|
136
|
-
children: nodes,
|
|
137
|
-
codepoint: u32(0),
|
|
138
|
-
ranges: ArrayList(CharRange).new(),
|
|
139
|
-
negated: false,
|
|
140
|
-
q_min: usize(0),
|
|
141
|
-
q_max: usize(0),
|
|
142
|
-
q_greedy: true,
|
|
143
|
-
group_index: usize(0),
|
|
144
|
-
anchor
|
|
125
|
+
kind :.Sequence,
|
|
126
|
+
children : nodes,
|
|
127
|
+
codepoint : u32(0),
|
|
128
|
+
ranges : ArrayList(CharRange).new(),
|
|
129
|
+
negated : false,
|
|
130
|
+
q_min : usize(0),
|
|
131
|
+
q_max : usize(0),
|
|
132
|
+
q_greedy : true,
|
|
133
|
+
group_index : usize(0),
|
|
134
|
+
anchor :.Start
|
|
145
135
|
)
|
|
146
136
|
),
|
|
147
|
-
|
|
148
137
|
// Create an alternation node (left | right)
|
|
149
138
|
alternation : (fn(left : RegexNode, right : RegexNode) -> Self)({
|
|
150
139
|
kids := ArrayList(RegexNode).new();
|
|
151
140
|
kids.push(left);
|
|
152
141
|
kids.push(right);
|
|
153
142
|
Self(
|
|
154
|
-
kind
|
|
155
|
-
children: kids,
|
|
156
|
-
codepoint: u32(0),
|
|
157
|
-
ranges: ArrayList(CharRange).new(),
|
|
158
|
-
negated: false,
|
|
159
|
-
q_min: usize(0),
|
|
160
|
-
q_max: usize(0),
|
|
161
|
-
q_greedy: true,
|
|
162
|
-
group_index: usize(0),
|
|
163
|
-
anchor
|
|
143
|
+
kind :.Alternation,
|
|
144
|
+
children : kids,
|
|
145
|
+
codepoint : u32(0),
|
|
146
|
+
ranges : ArrayList(CharRange).new(),
|
|
147
|
+
negated : false,
|
|
148
|
+
q_min : usize(0),
|
|
149
|
+
q_max : usize(0),
|
|
150
|
+
q_greedy : true,
|
|
151
|
+
group_index : usize(0),
|
|
152
|
+
anchor :.Start
|
|
164
153
|
)
|
|
165
154
|
}),
|
|
166
|
-
|
|
167
155
|
// Create a quantifier node (wrapping a child)
|
|
168
156
|
// max_val of 0 means unbounded (infinity)
|
|
169
157
|
quantifier : (fn(child : RegexNode, min_val : usize, max_val : usize, greedy : bool) -> Self)({
|
|
170
158
|
kids := ArrayList(RegexNode).new();
|
|
171
159
|
kids.push(child);
|
|
172
160
|
Self(
|
|
173
|
-
kind
|
|
174
|
-
children: kids,
|
|
175
|
-
codepoint: u32(0),
|
|
176
|
-
ranges: ArrayList(CharRange).new(),
|
|
177
|
-
negated: false,
|
|
178
|
-
q_min: min_val,
|
|
179
|
-
q_max: max_val,
|
|
180
|
-
q_greedy: greedy,
|
|
181
|
-
group_index: usize(0),
|
|
182
|
-
anchor
|
|
161
|
+
kind :.Quantifier,
|
|
162
|
+
children : kids,
|
|
163
|
+
codepoint : u32(0),
|
|
164
|
+
ranges : ArrayList(CharRange).new(),
|
|
165
|
+
negated : false,
|
|
166
|
+
q_min : min_val,
|
|
167
|
+
q_max : max_val,
|
|
168
|
+
q_greedy : greedy,
|
|
169
|
+
group_index : usize(0),
|
|
170
|
+
anchor :.Start
|
|
183
171
|
)
|
|
184
172
|
}),
|
|
185
|
-
|
|
186
173
|
// Create a capturing group node
|
|
187
174
|
group : (fn(child : RegexNode, index : usize) -> Self)({
|
|
188
175
|
kids := ArrayList(RegexNode).new();
|
|
189
176
|
kids.push(child);
|
|
190
177
|
Self(
|
|
191
|
-
kind
|
|
192
|
-
children: kids,
|
|
193
|
-
codepoint: u32(0),
|
|
194
|
-
ranges: ArrayList(CharRange).new(),
|
|
195
|
-
negated: false,
|
|
196
|
-
q_min: usize(0),
|
|
197
|
-
q_max: usize(0),
|
|
198
|
-
q_greedy: true,
|
|
199
|
-
group_index: index,
|
|
200
|
-
anchor
|
|
178
|
+
kind :.Group,
|
|
179
|
+
children : kids,
|
|
180
|
+
codepoint : u32(0),
|
|
181
|
+
ranges : ArrayList(CharRange).new(),
|
|
182
|
+
negated : false,
|
|
183
|
+
q_min : usize(0),
|
|
184
|
+
q_max : usize(0),
|
|
185
|
+
q_greedy : true,
|
|
186
|
+
group_index : index,
|
|
187
|
+
anchor :.Start
|
|
201
188
|
)
|
|
202
189
|
}),
|
|
203
|
-
|
|
204
190
|
// Create a non-capturing group node
|
|
205
191
|
non_capturing_group : (fn(child : RegexNode) -> Self)({
|
|
206
192
|
kids := ArrayList(RegexNode).new();
|
|
207
193
|
kids.push(child);
|
|
208
194
|
Self(
|
|
209
|
-
kind
|
|
210
|
-
children: kids,
|
|
211
|
-
codepoint: u32(0),
|
|
212
|
-
ranges: ArrayList(CharRange).new(),
|
|
213
|
-
negated: false,
|
|
214
|
-
q_min: usize(0),
|
|
215
|
-
q_max: usize(0),
|
|
216
|
-
q_greedy: true,
|
|
217
|
-
group_index: usize(0),
|
|
218
|
-
anchor
|
|
195
|
+
kind :.NonCapturingGroup,
|
|
196
|
+
children : kids,
|
|
197
|
+
codepoint : u32(0),
|
|
198
|
+
ranges : ArrayList(CharRange).new(),
|
|
199
|
+
negated : false,
|
|
200
|
+
q_min : usize(0),
|
|
201
|
+
q_max : usize(0),
|
|
202
|
+
q_greedy : true,
|
|
203
|
+
group_index : usize(0),
|
|
204
|
+
anchor :.Start
|
|
219
205
|
)
|
|
220
206
|
}),
|
|
221
|
-
|
|
222
207
|
// Create a backreference node (\1, \k<name>)
|
|
223
208
|
backreference : (fn(group_idx : usize) -> Self)(
|
|
224
209
|
Self(
|
|
225
|
-
kind
|
|
226
|
-
children: ArrayList(RegexNode).new(),
|
|
227
|
-
codepoint: u32(0),
|
|
228
|
-
ranges: ArrayList(CharRange).new(),
|
|
229
|
-
negated: false,
|
|
230
|
-
q_min: usize(0),
|
|
231
|
-
q_max: usize(0),
|
|
232
|
-
q_greedy: true,
|
|
233
|
-
group_index: group_idx,
|
|
234
|
-
anchor
|
|
210
|
+
kind :.Backreference,
|
|
211
|
+
children : ArrayList(RegexNode).new(),
|
|
212
|
+
codepoint : u32(0),
|
|
213
|
+
ranges : ArrayList(CharRange).new(),
|
|
214
|
+
negated : false,
|
|
215
|
+
q_min : usize(0),
|
|
216
|
+
q_max : usize(0),
|
|
217
|
+
q_greedy : true,
|
|
218
|
+
group_index : group_idx,
|
|
219
|
+
anchor :.Start
|
|
235
220
|
)
|
|
236
221
|
),
|
|
237
|
-
|
|
238
222
|
// Create a lookahead node (?=...) or (?!...)
|
|
239
223
|
// negated=false means positive, negated=true means negative
|
|
240
224
|
lookahead : (fn(child : RegexNode, positive : bool) -> Self)({
|
|
241
225
|
kids := ArrayList(RegexNode).new();
|
|
242
226
|
kids.push(child);
|
|
243
227
|
Self(
|
|
244
|
-
kind
|
|
245
|
-
children: kids,
|
|
246
|
-
codepoint: u32(0),
|
|
247
|
-
ranges: ArrayList(CharRange).new(),
|
|
248
|
-
negated: (!(positive)),
|
|
249
|
-
q_min: usize(0),
|
|
250
|
-
q_max: usize(0),
|
|
251
|
-
q_greedy: true,
|
|
252
|
-
group_index: usize(0),
|
|
253
|
-
anchor
|
|
228
|
+
kind :.Lookahead,
|
|
229
|
+
children : kids,
|
|
230
|
+
codepoint : u32(0),
|
|
231
|
+
ranges : ArrayList(CharRange).new(),
|
|
232
|
+
negated : (!(positive)),
|
|
233
|
+
q_min : usize(0),
|
|
234
|
+
q_max : usize(0),
|
|
235
|
+
q_greedy : true,
|
|
236
|
+
group_index : usize(0),
|
|
237
|
+
anchor :.Start
|
|
254
238
|
)
|
|
255
239
|
}),
|
|
256
|
-
|
|
257
240
|
// Create a lookbehind node (?<=...) or (?<!...)
|
|
258
241
|
// negated=false means positive, negated=true means negative
|
|
259
242
|
lookbehind : (fn(child : RegexNode, positive : bool) -> Self)({
|
|
260
243
|
kids := ArrayList(RegexNode).new();
|
|
261
244
|
kids.push(child);
|
|
262
245
|
Self(
|
|
263
|
-
kind
|
|
264
|
-
children: kids,
|
|
265
|
-
codepoint: u32(0),
|
|
266
|
-
ranges: ArrayList(CharRange).new(),
|
|
267
|
-
negated: (!(positive)),
|
|
268
|
-
q_min: usize(0),
|
|
269
|
-
q_max: usize(0),
|
|
270
|
-
q_greedy: true,
|
|
271
|
-
group_index: usize(0),
|
|
272
|
-
anchor
|
|
246
|
+
kind :.Lookbehind,
|
|
247
|
+
children : kids,
|
|
248
|
+
codepoint : u32(0),
|
|
249
|
+
ranges : ArrayList(CharRange).new(),
|
|
250
|
+
negated : (!(positive)),
|
|
251
|
+
q_min : usize(0),
|
|
252
|
+
q_max : usize(0),
|
|
253
|
+
q_greedy : true,
|
|
254
|
+
group_index : usize(0),
|
|
255
|
+
anchor :.Start
|
|
273
256
|
)
|
|
274
257
|
})
|
|
275
258
|
);
|
|
276
|
-
|
|
277
|
-
export
|
|
259
|
+
export(
|
|
278
260
|
RegexNode,
|
|
279
261
|
NodeKind,
|
|
280
262
|
CharRange,
|
|
281
263
|
AnchorKind,
|
|
282
264
|
GroupNameEntry
|
|
283
|
-
;
|
|
265
|
+
);
|