Category talk:Wren-pattern: Difference between revisions
Content added Content deleted
(→Source code: Bug fix.) |
m (→Source code: Typos and other minor errors.) |
||
Line 191: | Line 191: | ||
<lang ecmascript>/* Module "pattern.wren" */ |
<lang ecmascript>/* Module "pattern.wren" */ |
||
/* Match represents a single |
/* Match represents a single successful match made by methods in the Pattern class. |
||
Match objects are immutable. |
Match objects are immutable. |
||
*/ |
*/ |
||
Line 198: | Line 198: | ||
// from the start of the string and its capture list. This is a private constructor |
// from the start of the string and its capture list. This is a private constructor |
||
// intended to be called from the Pattern class as there should be no need for the user |
// intended to be called from the Pattern class as there should be no need for the user |
||
// to |
// to construct Match objects directly. |
||
construct new_(text, index, captures) { |
construct new_(text, index, captures) { |
||
if (!(text is String)) Fiber.abort("Match text must be a string.") |
if (!(text is String)) Fiber.abort("Match text must be a string.") |
||
Line 212: | Line 212: | ||
// Properties. |
// Properties. |
||
text { _text } // the text of the match |
text { _text } // the text of the match |
||
index { _index } // its |
index { _index } // its starting index (codepoints) |
||
length { _text.count } // its length |
length { _text.count } // its length |
||
span { [_index, index + length - 1] } // a list of its starting and ending indices |
span { [_index, index + length - 1] } // a list of its starting and ending indices |
||
Line 229: | Line 229: | ||
// as a codepoint offset from the start of the string. This is a private constructor |
// as a codepoint offset from the start of the string. This is a private constructor |
||
// intended to be called from the Pattern class as there should be no need for the user |
// intended to be called from the Pattern class as there should be no need for the user |
||
// to |
// to construct Capture objects directly. |
||
construct new_(text, index) { |
construct new_(text, index) { |
||
if (!(text is String)) Fiber.abort("Capture text must be a string.") |
if (!(text is String)) Fiber.abort("Capture text must be a string.") |
||
Line 241: | Line 241: | ||
// Properties. |
// Properties. |
||
text { _text } // the text of the capture |
text { _text } // the text of the capture |
||
index { _index } // its |
index { _index } // its starting index (codepoints) |
||
length { _text.count } // its length |
length { _text.count } // its length |
||
span { [_index, index + length - 1] } // a list of its starting and ending indices |
span { [_index, index + length - 1] } // a list of its starting and ending indices |
||
Line 972: | Line 972: | ||
// Type aliases for classes in case of any name clashes with other modules. |
// Type aliases for classes in case of any name clashes with other modules. |
||
var |
var Pattern_Match = Match |
||
var |
var Pattern_Capture = Capture |
||
var |
var Pattern_Pattern = Pattern |
||
Pattern.init_()</lang> |
Pattern.init_()</lang> |