Skip to content

Commit f68afb2

Browse files
committed
Add documentation to the top level common patterns.
1 parent 4bfb826 commit f68afb2

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

Sources/Patterns/Atomic Patterns/OneOf.swift

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,33 +153,46 @@ public func / <P: Pattern>(lhs: OrPattern<P, OneOf>, rhs: OneOf) -> OrPattern<P,
153153

154154
// MARK: Common patterns.
155155

156-
/// Succeeds anywhere except for the end of input, and consumes 1 element.
156+
/// Succeeds anywhere except for at the end of input, and consumes 1 element.
157157
public let any = OneOf(description: "any", regex: #"[.\p{Zl}]"#,
158158
contains: { _ in true })
159-
public let alphanumeric = OneOf(description: "alphanumeric", regex: #"(?:\p{Alphabetic}|\p{Nd})"#,
160-
contains: { $0.isWholeNumber || $0.isLetter })
161-
public let digit = OneOf(description: "digit", regex: #"\p{Nd}"#,
162-
contains: { $0.isWholeNumber })
159+
/// Matches one character representing a letter, i.e. where `Character.isLetter` is `true`.
163160
public let letter = OneOf(description: "letter", regex: #"\p{Alphabetic}"#,
164161
contains: { $0.isLetter })
162+
/// Matches one character representing a lowercase character, i.e. where `Character.isLowercase` is `true`.
165163
public let lowercase = OneOf(description: "lowercase", regex: #"\p{Ll}"#,
166164
contains: { $0.isLowercase })
165+
/// Matches one character representing an uppercase character, i.e. where `Character.isUppercase` is `true`.
166+
public let uppercase = OneOf(description: "uppercase", regex: #"\p{Lu}"#,
167+
contains: { $0.isUppercase })
168+
/// Matches one character representing a whole number, i.e. where `Character.isWholeNumber` is `true`.
169+
public let digit = OneOf(description: "digit", regex: #"\p{Nd}"#,
170+
contains: { $0.isWholeNumber })
171+
/// Matches one letter or one digit.
172+
public let alphanumeric = OneOf(description: "alphanumeric", regex: #"(?:\p{Alphabetic}|\p{Nd})"#,
173+
contains: { $0.isWholeNumber || $0.isLetter })
174+
/// Matches one character representing a newline, i.e. where `Character.isNewline` is `true`.
167175
public let newline = OneOf(description: "newline", regex: #"\p{Zl}"#,
168176
contains: { $0.isNewline })
177+
/// Matches one character representing whitespace (including newlines), i.e. where `Character.isWhitespace` is `true`.
178+
public let whitespace = OneOf(description: "whitespace", regex: #"\p{White_Space}"#,
179+
contains: { $0.isWhitespace })
180+
/// Matches one character representing punctuation, i.e. where `Character.isPunctuation` is `true`.
169181
public let punctuation = OneOf(description: "punctuation", regex: #"\p{P}"#,
170182
contains: { $0.isPunctuation })
183+
/// Matches one character representing a symbol, i.e. where `Character.isSymbol` is `true`.
171184
public let symbol = OneOf(description: "symbol", regex: #"\p{S}"#,
172185
contains: { $0.isSymbol })
173-
public let uppercase = OneOf(description: "uppercase", regex: #"\p{Lu}"#,
174-
contains: { $0.isUppercase })
175-
public let whitespace = OneOf(description: "whitespace", regex: #"\p{White_Space}"#,
176-
contains: { $0.isWhitespace })
186+
/// Matches one character representing a hexadecimal digit, i.e. where `Character.isHexDigit` is `true`.
177187
public let hexDigit = OneOf(description: "hexDigit", regex: #"\p{Hex_Digit}"#,
178188
contains: { $0.isHexDigit })
189+
/// Matches one ASCII character, i.e. where `Character.isASCII` is `true`.
179190
public let ascii = OneOf(description: "ascii", regex: #"[[:ascii:]]"#,
180191
contains: { $0.isASCII }) // regex might also be [ -~] or [\x00-\x7F]
192+
/// Matches one character representing a mathematical symbol, i.e. where `Character.isMathSymbol` is `true`.
181193
public let mathSymbol = OneOf(description: "mathSymbol", regex: #"\p{Sm}"#,
182194
contains: { $0.isMathSymbol })
195+
/// Matches one character representing a currency symbol, i.e. where `Character.isCurrencySymbol` is `true`.
183196
public let currencySymbol = OneOf(description: "currencySymbol", regex: #"\p{Sc}"#,
184197
contains: { $0.isCurrencySymbol })
185198

0 commit comments

Comments
 (0)