
1 // 2 // Copyright (c) 2007, Brian Frank and Andy Frank 3 // Licensed under the Academic Free License version 3.0 4 // 5 // History: 6 // 26 Dec 07 Brian Frank Creation 7 // 8 9 ** 10 ** RegexMatcher is used to matching operations 11 ** on a regular expression. 12 ** 13 final class RegexMatcher 14 { 15 16 ////////////////////////////////////////////////////////////////////////// 17 // Constructor 18 ////////////////////////////////////////////////////////////////////////// 19 20 ** 21 ** Private constructor. 22 ** 23 private new make() 24 25 ////////////////////////////////////////////////////////////////////////// 26 // Matching Operations 27 ////////////////////////////////////////////////////////////////////////// 28 29 ** 30 ** Match the entire region against the pattern. If a match 31 ** is made then return true - additional info is available 32 ** via the `group`, `start`, and `end` methods. Return false 33 ** if a match cannot be made. 34 ** 35 Bool matches() 36 37 ** 38 ** Attempt to find the next match . If a match is made 39 ** then return true - additional info is available via 40 ** the `group`, `start`, and `end` methods. Return false 41 ** if a match cannot be made. 42 ** 43 Bool find() 44 45 ////////////////////////////////////////////////////////////////////////// 46 // Group 47 ////////////////////////////////////////////////////////////////////////// 48 49 ** 50 ** Return the number of capturing groups or zero if no match. 51 ** Group zero is is not included. 52 ** 53 Int groupCount() 54 55 ** 56 ** Return the substring captured by the matching operation. 57 ** Group index zero denotes the entire pattern and capturing 58 ** groups are indexed from left to right starting at one. 59 ** Throw exception if failed to match input or group 60 ** index is invalid. 61 ** 62 Str group(Int group := 0) 63 64 ** 65 ** Return the start index of the given `group`. 66 ** Throw exception if failed to match input or group 67 ** index is invalid. 68 ** 69 Int start(Int group := 0) 70 71 ** 72 ** Return end index+1 one of the given `group`. 73 ** Throw exception if failed to match input or group 74 ** index is invalid. 75 ** 76 Int end(Int group := 0) 77 78 79 // TODO: lots more functionality needed 80 // TODO: examples in fandoc 81 82 }