brex.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. /* BREX: Beoran's regular expressions, 2013. MIT license. */
  2. typedef struct BrexState_ BrexState;
  3. typedef struct BrexRegexp_ BrexRegexp;
  4. typedef struct BrexCompiled_ BrexCompiled;
  5. /* Regexps are compiled to a nondeterministic state machine.
  6. */
  7. struct BrexState_ {
  8. int match; /* Character that this state matches */
  9. BrexState ** out;
  10. int max_out;
  11. };
  12. /* These values are compatible with MRI. */
  13. #define BREX_IGNORECASE 1
  14. #define BREX_MULTILINE 4
  15. struct BrexRegexp_ {
  16. const char * source;
  17. int flags;
  18. BrexCompiled * compiled;
  19. /* Add compiled regexp structure here... Also add matches. */
  20. };
  21. /*
  22. Relevant part of spec for implementation reinterpreted:
  23. Regexp must have a pattern that may not be NULL, except for initialization.
  24. Regexp must have a ignore case flag that's false by default.
  25. Regexp must have a multiline flag (or .) that's false by default.
  26. There's a IGNORECASE constant that's a power of two.
  27. There's a MULTILINE constant that's also a different power of two.
  28. These two are used to set the flags on the regexp.
  29. Syntax of regexp patterns:
  30. Patterns
  31. pattern ::
  32. alternative
  33. | pattern 1 | alternative 2
  34. alternative ::
  35. [ empty ]
  36. | alternative 3 term
  37. term ::
  38. anchor
  39. | atom 1
  40. | atom 2 quantifier
  41. anchor ::
  42. left-anchor | right-anchor
  43. left-anchor ::
  44. \A | ^
  45. right-anchor ::
  46. \z | ~
  47. quantifier ::
  48. * | + | ?
  49. atom ::
  50. pattern-character
  51. | grouping
  52. | .
  53. | atom-escape-sequence
  54. pattern-character ::
  55. source-character but not regexp-meta-character
  56. regexp-meta-character ::
  57. | | . | * | + | ^ | ? | ( | ) | # | \ | $
  58. | future-reserved-meta-character
  59. future-reserved-meta-character ::
  60. [ | ] | { | }
  61. grouping ::
  62. ( pattern )
  63. atom-escape-sequence ::
  64. decimal-escape-sequence
  65. | regexp-character-escape-sequence
  66. decimal-escape-sequence ::
  67. \ decimal-digit-except-zero
  68. regexp-character-escape-sequence ::
  69. regexp-escape-sequence
  70. | regexp-non-escaped-sequence
  71. | hexadecimal-escape-sequence
  72. | regexp-octal-escape-sequence
  73. | regexp-control-escape-sequence
  74. regexp-escape-sequence ::
  75. \ regexp-escaped-character
  76. regexp-escaped-character ::
  77. n | t | r | f | v | a | e
  78. regexp-non-escaped-sequence ::
  79. \ regexp-meta-character
  80. regexp-octal-escape-sequence ::
  81. octal-escape-sequence but not decimal-escape-sequence
  82. regexp-control-escape-sequence ::
  83. \ ( C- | c ) regexp-control-escaped-character
  84. regexp-control-escaped-character ::
  85. regexp-character-escape-sequence
  86. | ?
  87. | source-character but not ( \ | ? )
  88. Future-reserved-meta-character s are reserved for the extension of the pattern of regular expressions.
  89. Regexp Semantics
  90. A regular expression selects specific substrings from a string called a target string according to the pattern of the regular expression. If the pattern matches more than one substring, the substring which begins earliest in the target string is selected. If there is more than one such substring beginning at that point, the substring that has the highest priority, which is described
  91. below, is selected. Each component of the pattern matches a substring of the target string as follows:
  92. a) A pattern matches the following substring:
  93. 1) If the pattern is an alternative 1 , it matches the string matched with
  94. the alternative 1 .
  95. 2) If the pattern is a pattern 1 | alternative 2 , it matches the string
  96. matched with either the pattern 1 or the alternative 2 . The one matched
  97. with the pattern 1 has a higher priority.
  98. EXAMPLE 1: "ab".slice(/(a|ab)/) returns "a", not "ab".
  99. b) An alternative matches the following substring:
  100. 1) If the alternative is [empty], it matches an empty string.
  101. 2) If the alternative is an alternative 3 term, the alternative matches
  102. the substring whose first part is matched with the alternative 3 and
  103. whose rest part is matched with the term.
  104. If there is more than one such substring, the priority of the substrings is determined as follows:
  105. i) If there is more than one candidate which is matched with the
  106. alternative 3 , a substring whose first part is a candidate with
  107. a higher priority has a higher priority.
  108. EXAMPLE 2: "abc".slice(/(a|ab)(c|b)/) returns "ab", not "abc". In this case,
  109. (a|ab) is prior to (c|b).
  110. ii) If the first parts of substrings are the same, and if there is more
  111. than one candidate which is matched with the term, a substring whose
  112. rest part is a candidate with a higher priority has a higher priority.
  113. EXAMPLE 3: "abc".slice(/a(b|bc)/) returns "ab", not "abc".
  114. c) A term matches the following substring:
  115. 1) If the term is an atom 1 , it matches the string matched with the atom 1.
  116. 2) If the term is an atom 2 quantifier, it matches a string as follows:
  117. i) If the quantifier is *, it matches a sequence of zero or more strings
  118. matched with the atom 2.
  119. ii) If the quantifier is +, it matches a sequence of one or more strings
  120. matched with atom 2.
  121. iii) If the quantifier is ?, it matches a sequence of zero or one string matched with the atom 2. A longer sequence has a higher priority.
  122. EXAMPLE 4: "aaa".slice(/a* /) returns "aaa", none of "", "a", and "aa".
  123. (above it was /a* / without a space, which would end the C comment.)
  124. 3) If the term is an anchor, it matches the empty string at a specific
  125. position within the target string S, as follows:
  126. i) If the anchor is \A, it matches an empty string at the beginning of S.
  127. ii) If the anchor is ^, it matches an empty string at the beginning of S or
  128. just after a line-terminator which is followed by at least one character.
  129. iii) If the anchor is \z, it matches an empty string at the end of S.
  130. iv) If the anchor is ~, it matches an empty string at the end of S or just before a line-terminator.
  131. d) An atom matches the following substring:
  132. 1) If the atom is a pattern-character, it matches a character C represented
  133. by the pattern-character. If the atom is present in the pattern of an
  134. instance of the class Regexp whose ignorecase-flag attribute is true, it
  135. also matches a corresponding upper-case character of C, if C is a lower-case
  136. character, or a corresponding lower-case character of C, if C
  137. is an upper-case character.
  138. 2) If the atom is a grouping, it matches the string matched with the grouping.
  139. 3) If the atom is “.”, it matches any character except for a line-terminator.
  140. If the atom is present in the pattern of an instance of the class Regexp
  141. whose multiline-flag attribute is true, it also matches a line-terminator.
  142. 4) If the atom is an atom-escape-sequence, it matches the string matched with
  143. the atom-escape-sequence.
  144. e) A grouping matches the substring matched with the pattern.
  145. f) An atom-escape-sequence matches the following substring:
  146. 1) If the atom-escape-sequence is a decimal-escape-sequence, it matches the
  147. string matched with the decimal-escape-sequence.
  148. 2) If the atom-escape-sequence is a regexp-character-escape-sequence, it
  149. matches a string of length one, the content of which is the character
  150. represented by the regexp-character-escape-sequence.
  151. g)
  152. A decimal-escape-sequence matches the following substring:
  153. 1) Let i be an integer represented by decimal-digit-except-zero.
  154. 2) Let G be the i th grouping in the pattern, counted from 1, in the order
  155. of the occurrence of “(” of groupings from the left of the pattern.
  156. 3) If the decimal-escape-sequence is present before G within the pattern,
  157. it does not match any string.
  158. 4) If G matches any string, the decimal-escape-sequence matches the same
  159. string.
  160. 5) Otherwise, the decimal-escape-sequence does not match any string.
  161. h) A regexp-character-escape-sequence represents a character as follows:
  162. A regexp-escape-sequence represents a character as shown in 8.7.6.3.3, Table 1.
  163. i) A regexp-non-escaped-sequence represents a regexp-meta-character.
  164. j) A hexadecimal-escape-sequence represents a character as described in 8.7.6.3.3.
  165. k) A regexp-octal-escape-sequence is interpreted in the same way as an octal-escape-sequence (see 8.7.6.3.3).
  166. l) A regexp-control-escape-sequence represents a character, the code of which is com-puted by taking bitwise AND of 0x9f and the code of the character represented by the regexp-control-escaped-character, except when the regexp-control-escaped-character is ?, in which case, the regexp-control-escape-sequence represents a character whose code is 127.
  167. Matching process
  168. A pattern P is considered to successfully match the given string S, if there exists a substring of S (including S itself) matched with P.
  169. a)
  170. When an index is specified, it is tested if P matches the part of S which begins at the index and ends at the end of S. However, if the match succeeds, the string attribute of theresulting instance of the class MatchData is S, not the part of S which begins at the index, as described below.
  171. b)
  172. A matching process returns either an instance of the class MatchData (see 15.2.16) if the match succeeds or nil if the match fails.
  173. c)
  174. An instance of the class MatchData is created as follows:
  175. 1) Let B be the substring of S which P matched.
  176. 2) Create a direct instance of the class MatchData, and let M be the instance.
  177. 3) Set the string attribute of M (see 15.2.16.1) to S.
  178. 4) Create a new empty list L.
  179. 5) Let O be a pair of the substring B and the index of the first character of B within S. Append O to L.
  180. 6) For each grouping G in P, in the order of the occurrence of its “(” within P, take the following steps:
  181. 9 i) If G matches a substring of B under the matching process of P, let BG be the substring. Let O be a pair of the substring BG and the index of the first character of BG within S. Append O to L.
  182. ii) Otherwise, append to L a pair whose substring and index of the substring are nil.
  183. 7) Set the match result attribute of M to L.
  184. 8) M is the instance of the class MatchData returned by the matching process.
  185. A matching process creates or updates a local variable binding with name “$~”, which is specifically used by the method Regexp.last match (see 15.2.15.6.3), as follows:
  186. 1) Let M be the value which the matching process returns.
  187. 2) If the binding for the name “_̃” can be resolved by the process described in as if “_̃” were a local-variable-identifier, replace the value of the binding with M.
  188. 3) Otherwise, create a local variable binding with name "_̃” and value M in the uppermost non-block element of [local-variable-bindings] where the non-block element means the element which does not correspond to a block.
  189. d)
  190. A conforming processor may name the binding other than “_̃”; however, it shall not be of the form local-variable-identifier.
  191. Singleton methods
  192. Regexp.compile( *args )
  193. Behavior: Same as the method new (see 15.2.3.3.3).
  194. Regexp.escape
  195. Regexp.escape( string )
  196. Behavior:
  197. a) If string is not an instance of the class String, the behavior is unspecified.
  198. b) Let S be the content of string.
  199. c) Return a a new direct instance of the class String whose content is the same as S,
  200. except that every occurrences of characters on the left of Table 4 are replaced with the
  201. corresponding sequences of characters on the right of Table 4.
  202. Table 4 – Regexp escaped characters
  203. Characters replaced Escaped sequence
  204. 0x0a 0x09 \f
  205. 0x20 \ 0x20
  206. # \#
  207. ~ \~
  208. ( \(
  209. ) \)
  210. * \*
  211. + \+
  212. - \-
  213. . \.
  214. ? \?
  215. [ \[
  216. \ \\
  217. ] \]
  218. ^ \^
  219. { \{
  220. | \|
  221. }
  222. 10
  223. \r
  224. 0x0c
  225. 15.2.15.6.3
  226. \t
  227. 0x0d
  228. 9
  229. \n
  230. \}
  231. Regexp.last match
  232. Regexp.last match( *index )
  233. 227
  234. 1 Visibility: public
  235. 2 Behavior:
  236. 3 a) Search for a binding of a local variable with name “ ̃” as described in 9.2 as if “ ̃” were
  237. a local-variable-identifier.
  238. b) If the binding is found and its value is an instance of the class MatchData, let M be
  239. the instance. Otherwise, return nil.
  240. 7 c) If the length of index is 0, return M.
  241. 8 d) If the length of index is larger than 1, raise a direct instance of the class ArgumentError.
  242. 9 e) If the length of index is 1, let A be the only argument.
  243. 10 f) If A is not an instance of the class Integer, the behavior of the method is unspecified.
  244. 11 g) Let R be the result returned by invoking the method [] (see 15.2.16.3.1) on M with
  245. A as the only argument.
  246. 13 h) Return R.
  247. 14 15.2.15.6.4
  248. 4
  249. 5
  250. 6
  251. 12
  252. Regexp.quote
  253. 15 Regexp.quote
  254. 16 Visibility: public
  255. 17 Behavior: Same as the method escape (see 15.2.15.6.2).
  256. 18 15.2.15.7
  257. 19 15.2.15.7.1
  258. Instance methods
  259. Regexp#initialize
  260. 20 initialize( source, flag =nil )
  261. 21 Visibility: private
  262. 22 Behavior:
  263. 23 a) If source is an instance of the class Regexp, let S be the pattern attribute of source.
  264. If source is an instance of the class String, let S be the content of source. Otherwise,
  265. the behavior is unspecified.
  266. b) If S is not of the form pattern (see 15.2.15.4), raise a direct instance of the class
  267. RegexpError.
  268. c) Set the pattern attribute of the receiver to S.
  269. 24
  270. 25
  271. 26
  272. 27
  273. 28
  274. 228
  275. 1
  276. d)
  277. If flag is an instance of the class Integer, let n be the value of the instance.
  278. 1) If computing bitwise AND of the value of the constant IGNORECASE of the class
  279. Regexp and n results in non-zero value, set the ignorecase-flag attribute of the
  280. receiver to true.
  281. 2)
  282. 2
  283. If computing bitwise AND of the value of the constant MULTILINE of the class
  284. Regexp and n results in non-zero value, set the multiline-flag attribute of the
  285. receiver to true.
  286. 3
  287. 4
  288. 5
  289. 6
  290. 7
  291. 8
  292. e) If flag is not an instance of the class Integer, and if flag is a trueish object, then set
  293. the ignorecase-flag attribute of the receiver to true.
  294. f) Return an implementation-defined value.
  295. 9
  296. 10
  297. 11
  298. 15.2.15.7.2
  299. Regexp#initialize copy
  300. 12 initialize copy( original )
  301. 13 Visibility: private
  302. 14 Behavior:
  303. 15 a) If original is not an instance of the class of the receiver, raise a direct instance of the
  304. class TypeError.
  305. 17 b) Set the pattern attribute of the receiver to the pattern attribute of original .
  306. 18 c) Set the ignorecase-flag attribute of the receiver to the ignorecase-flag attribute of orig-
  307. inal .
  308. 20 d) Set the multiline-flag attribute of the receiver to the multiline-flag attribute of original .
  309. 21 e) Return an implementation-defined value.
  310. 16
  311. 19
  312. 22
  313. 15.2.15.7.3
  314. Regexp#==
  315. 23 = =( other )
  316. 24 Visibility: public
  317. 25 Behavior:
  318. 26 a) If other is not an instance of the class Regexp, return false.
  319. 27 b) If the corresponding attributes of the receiver and other are the same, return true.
  320. 28 c) Otherwise, return false.
  321. 229
  322. 1
  323. 15.2.15.7.4
  324. Regexp#===
  325. 2 = = =( string )
  326. 3 Visibility: public
  327. 4 Behavior:
  328. 5 a) If string is not an instance of the class String, the behavior is unspecified.
  329. 6 b) Let S be the content of string.
  330. 7 c) Test if the pattern of the receiver matches S (see 15.2.15.4 and 15.2.15.5). Let M be
  331. the result of the matching process.
  332. 9 d) If M is an instance of the class MatchData, return true.
  333. 10 e) Otherwise, return false.
  334. 15.2.15.7.5
  335. Regexp#= ̃
  336. 8
  337. 11
  338. 12 =~( string )
  339. 13 Visibility: public
  340. 14 Behavior:
  341. 15 a) If string is not an instance of the class String, the behavior is unspecified.
  342. 16 b) Let S be the content of string.
  343. 17 c) Test if the pattern of the receiver matches S (see 15.2.15.4 and 15.2.15.5). Let M be
  344. the result of the matching process.
  345. 19 d) If M is nil return nil.
  346. 20 e) If M is an instance of the class MatchData, let P be first element of the match result
  347. attribute of M, and let i be the index of the substring of P.
  348. f) Return an instance of the class Integer whose value is i.
  349. 18
  350. 21
  351. 22
  352. 23
  353. 15.2.15.7.6
  354. Regexp#casefold?
  355. 24 casefold?
  356. 25 Visibility: public
  357. 26 Behavior: The method returns the value of the ignorecase-flag attribute of the receiver.
  358. 230
  359. 1
  360. 15.2.15.7.7
  361. Regexp#match
  362. 2 match( string )
  363. 3 Visibility: public
  364. 4 Behavior:
  365. 5 a) If string is not an instance of the class String, the behavior is unspecified.
  366. 6 b) Let S be the content of string.
  367. 7 c) Test if the pattern of the receiver matches S (see 15.2.15.4 and 15.2.15.5). Let M be
  368. the result of the matching process.
  369. 9 d) Return M.
  370. 10 15.2.15.7.8
  371. 11 source
  372. 12 Visibility: public
  373. 8
  374. 13
  375. 14
  376. Behavior: The method returns a direct instance of the class String whose content is the
  377. pattern of the receiver.
  378. 15 15.2.16
  379. 16 15.2.16.1
  380. 17
  381. 18
  382. 19
  383. 20
  384. 21
  385. 22
  386. 23
  387. 24
  388. 25
  389. 26
  390. 27
  391. 28
  392. 29
  393. 30
  394. 31
  395. Regexp#source
  396. MatchData
  397. General description
  398. Instances of the class MatchData represent results of successful matches of instances of the class
  399. Regexp against instances of the class String.
  400. An instance of the class MatchData has the attributes called string and match result, which
  401. are initialized as described in 15.2.15.5. The string attribute is the target string S of a matching
  402. process. The match result attribute is a list whose element is a pair of a substring B matched
  403. by the pattern of an instance of the class Regexp or a grouping in the pattern, and the index I
  404. of the first character of B within S. B is called the substring of the element, and I is called the
  405. index of the substring of the element. Elements of the match result attribute are indexed by
  406. integers starting from 0.
  407. Given an instance M of the class MatchData, three values named matched substring, pre-
  408. match and post-match of M, respectively, are defined as follows:
  409. Let S be the string attribute of M. Let F be the first element of the match result attribute of
  410. M. Let B and O be the substring of F and the index of the substring of F. Let i be the sum of
  411. O and the length of B.
  412. matched substring: The matched substring of M is B.
  413. 231
  414. pre-match: The pre-match of M is a part of S, from the first up to, but not including the
  415. Oth character of S.
  416. 1
  417. 2
  418. post-match: The post-match of M is a part of S, from the i th up to the last character of
  419. S.
  420. 3
  421. 4
  422. 5 15.2.16.2
  423. 6 The class Object
  424. 7 15.2.16.3
  425. 8 15.2.16.3.1
  426. Instance methods
  427. MatchData#[]
  428. []( *args )
  429. 9
  430. Visibility: public
  431. 10
  432. Behavior: Invoke the method to a on the receiver (see 15.2.16.3.12), and invoke the
  433. method [] on the resulting instance of the class Array with args as the arguments (see
  434. 15.2.12.5.4), and then, return the resulting value of the invocation of the method [].
  435. 11
  436. 12
  437. 13
  438. 14
  439. Direct superclass
  440. 15.2.16.3.2
  441. MatchData#begin
  442. 15 begin( index )
  443. 16 Visibility: public
  444. 17 Behavior:
  445. 18 a) If index is not an instance of the class Integer, the behavior is unspecified.
  446. 19 b) Let L be the match result attribute of the receiver, and let i be the value of index .
  447. 20 c) If i is smaller than 0, or larger than or equal to the number of elements of L, raise a
  448. direct instance of the class IndexError.
  449. 22 d) Otherwise, return the second portion of the i th element of L.
  450. 23 15.2.16.3.3
  451. 21
  452. MatchData#captures
  453. 24 captures
  454. 25 Visibility: public
  455. 26 Behavior:
  456. 232
  457. 1 a) Let L be the match result attribute of the receiver.
  458. 2 b) Create an empty direct instance A of the class Array.
  459. 3 c) Except for the first element, for each element e of L, in the same order in the list,
  460. append to A a direct instance of the class String whose content is the substring of e.
  461. 5 d) Return A.
  462. 6 15.2.16.3.4
  463. 4
  464. MatchData#end
  465. 7 end( index )
  466. 8 Visibility: public
  467. 9 Behavior:
  468. 10 a) If index is not an instance of the class Integer, the behavior is unspecified.
  469. 11 b) Let L be the match result attribute of the receiver, and let i be the value of index .
  470. 12 c) If i is smaller than 0, or larger than or equal to the number of elements of L, raise a
  471. direct instance of the class IndexError.
  472. d) Let F and S be the substring and the index of the substring of the i th element of L,
  473. respectively.
  474. 16 e) If F is nil, return nil.
  475. 17 f) Otherwise, let f be the length of F. Return an instance of the class Integer whose
  476. value is the sum of S and f.
  477. 13
  478. 14
  479. 15
  480. 18
  481. 19
  482. 15.2.16.3.5
  483. MatchData#initialize copy
  484. 20 initialize copy( original )
  485. 21 Visibility: private
  486. 22 Behavior:
  487. 23 a) If original is not an instance of the class of the receiver, raise a direct instance of the
  488. class TypeError.
  489. 25 b) Set the string attribute of the receiver to the string attribute of original .
  490. 26 c) Set the match result attribute of the receiver to the match result attribute of original .
  491. 27 d) Return an implementation-defined value.
  492. 24
  493. 233
  494. 1 15.2.16.3.6
  495. 2 length
  496. 3 Visibility: public
  497. 4 Behavior:
  498. 5 The method returns the number of elements of the match result attribute of the receiver.
  499. 6
  500. 15.2.16.3.7
  501. MatchData#length
  502. MatchData#offset
  503. 7 offset( index )
  504. 8 Visibility: public
  505. 9 Behavior:
  506. 10 a) If index is not an instance of the class Integer, the behavior is unspecified.
  507. 11 b) Let L be the match result attribute of the receiver, and let i be the value of index .
  508. 12 c) If i is smaller than 0, or larger than or equal to the number of elements of L, raise a
  509. direct instance of the class IndexError.
  510. d) Let S and b be the substring and the index of the substring of the i th element of L,
  511. respectively. Let e be the sum of b and the length of S.
  512. e) Return a new instance of the class Array which contains two instances of the class
  513. Integer, the one whose value is b and the other whose value is e, in this order.
  514. 13
  515. 14
  516. 15
  517. 16
  518. 17
  519. 18
  520. 15.2.16.3.8
  521. MatchData#post match
  522. 19 post match
  523. 20 Visibility: public
  524. Behavior: The method returns an instance of the class String the content of which is the
  525. post-match of the receiver.
  526. 21
  527. 22
  528. 23
  529. 15.2.16.3.9
  530. MatchData#pre match
  531. 24 pre match
  532. 25 Visibility: public
  533. Behavior: The method returns an instance of the class String the content of which is the
  534. pre-match of the receiver.
  535. 26
  536. 27
  537. 234
  538. 1 15.2.16.3.10
  539. 2 size
  540. 3 Visibility: public
  541. 4 Behavior: Same as the method length (see 15.2.16.3.6).
  542. 5
  543. 15.2.16.3.11
  544. MatchData#size
  545. MatchData#string
  546. 6 string
  547. 7 Visibility: public
  548. 8 Behavior:
  549. 9
  550. 10
  551. The method returns an instance of the class String the content of which is the string
  552. attribute of the receiver.
  553. 11 15.2.16.3.12
  554. 12 to a 13 Visibility: public
  555. 14 Behavior:
  556. 15 a) Let L be the match result attribute of the receiver.
  557. 16 b) Create an empty direct instance A of the class Array.
  558. 17 c) For each element e of L, in the same order in the list, append to A an instance of the
  559. class String whose content is the substring of e.
  560. d) Return A.
  561. 18
  562. 19
  563. MatchData#to a
  564. 20 15.2.16.3.13
  565. 21 to s
  566. 22 Visibility: public
  567. 23
  568. 24
  569. MatchData#to s
  570. Behavior: The method returns an instance of the class String the content of which is the
  571. matched substring of the receiver.
  572. 235
  573. */