File tree Expand file tree Collapse file tree 2 files changed +34
-34
lines changed
Expand file tree Collapse file tree 2 files changed +34
-34
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,40 @@ extension _BuiltinRegexComponent {
3232 }
3333}
3434
35+ // MARK: - Primitive regex components
36+
37+ extension String : RegexComponent {
38+ public typealias Output = Substring
39+
40+ public var regex : Regex < Output > {
41+ . init( node: . quotedLiteral( self ) )
42+ }
43+ }
44+
45+ extension Substring : RegexComponent {
46+ public typealias Output = Substring
47+
48+ public var regex : Regex < Output > {
49+ . init( node: . quotedLiteral( String ( self ) ) )
50+ }
51+ }
52+
53+ extension Character : RegexComponent {
54+ public typealias Output = Substring
55+
56+ public var regex : Regex < Output > {
57+ . init( node: . atom( . char( self ) ) )
58+ }
59+ }
60+
61+ extension UnicodeScalar : RegexComponent {
62+ public typealias Output = Substring
63+
64+ public var regex : Regex < Output > {
65+ . init( node: . atom( . scalar( self ) ) )
66+ }
67+ }
68+
3569// MARK: - Combinators
3670
3771// MARK: Concatenation
Original file line number Diff line number Diff line change @@ -97,37 +97,3 @@ extension Regex {
9797 }
9898
9999}
100-
101- // MARK: - Primitive regex components
102-
103- extension String : RegexComponent {
104- public typealias Output = Substring
105-
106- public var regex : Regex < Output > {
107- . init( node: . quotedLiteral( self ) )
108- }
109- }
110-
111- extension Substring : RegexComponent {
112- public typealias Output = Substring
113-
114- public var regex : Regex < Output > {
115- . init( node: . quotedLiteral( String ( self ) ) )
116- }
117- }
118-
119- extension Character : RegexComponent {
120- public typealias Output = Substring
121-
122- public var regex : Regex < Output > {
123- . init( node: . atom( . char( self ) ) )
124- }
125- }
126-
127- extension UnicodeScalar : RegexComponent {
128- public typealias Output = Substring
129-
130- public var regex : Regex < Output > {
131- . init( node: . atom( . scalar( self ) ) )
132- }
133- }
You can’t perform that action at this time.
0 commit comments