Inheritance: IronRuby.Builtins.RubyObject
 private void InitializeFrom(StringScanner/*!*/ other) {
     _currentPosition = other._currentPosition;
     _foundPosition = other._foundPosition;
     _lastMatch = other._lastMatch;
     _lastMatchingGroups = other._lastMatchingGroups;
     _previousPosition = other._previousPosition;
     _scanString = other.ScanString;
 }
Exemple #2
0
 public static bool IsRestLeft(StringScanner/*!*/ self)
 {
     return self.CurrentPosition < self.Length;
 }
Exemple #3
0
 public static MutableString GetString(StringScanner/*!*/ self)
 {
     return self.ScanString;
 }
Exemple #4
0
 public static int GetCurrentPosition(StringScanner/*!*/ self)
 {
     return self.CurrentPosition;
 }
Exemple #5
0
 public static StringScanner Unscan(StringScanner/*!*/ self)
 {
     if (self.LastMatch == null) {
         // throw Exception StringScanner::Error
         throw RubyExceptions.CreateRangeError("unscan failed: previous match had failed");
     }
     int position = self.PreviousPosition;
     self.Reset();
     self.CurrentPosition = position;
     return self;
 }
Exemple #6
0
 public static int SetCurrentPosition(StringScanner/*!*/ self, int newPosition)
 {
     int newPos = newPosition;
     if (newPos < 0) {
         newPos = self.Length - self.CurrentPosition;
     }
     if (newPos > self.Length) {
         throw RubyExceptions.CreateRangeError("index out of range");
     }
     self.CurrentPosition = newPos;
     return newPosition;
 }
Exemple #7
0
 public static int RestSize(StringScanner/*!*/ self)
 {
     return (self.CurrentPosition < self.Length) ? (self.Length - self.CurrentPosition) : 0;
 }
Exemple #8
0
 public static MutableString PreMatch(StringScanner/*!*/ self)
 {
     if (self.LastMatch == null) {
         return null;
     }
     return self.ScanString.GetSlice(0, self.FoundPosition);
 }
Exemple #9
0
 public static bool WasMatched(StringScanner /*!*/ self)
 {
     return(self.LastMatch != null);
 }
Exemple #10
0
 public static MutableString ToString(StringScanner /*!*/ self)
 {
     return(MutableString.Create(self.ToString(), self._scanString.Encoding));
 }
Exemple #11
0
 public static bool EndOfLine(StringScanner /*!*/ self)
 {
     return(self.CurrentPosition >= self.Length);
 }
Exemple #12
0
 public static MutableString CheckUntil(StringScanner /*!*/ self, [NotNull] RubyRegex /*!*/ pattern)
 {
     return(SearchFull(self, pattern, false, true) as MutableString);
 }
Exemple #13
0
 public static bool BeginningOfLine(StringScanner /*!*/ self)
 {
     return((self.CurrentPosition == 0) || (self.ScanString.GetChar(self.CurrentPosition - 1) == '\n'));
 }
Exemple #14
0
 public static StringScanner Concat(StringScanner /*!*/ self, MutableString str)
 {
     self.ScanString.Append(str);
     return(self);
 }
Exemple #15
0
 public static void Reinitialize(StringScanner /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ scan)
 {
     self.ScanString = scan;
     self.Reset();
 }
Exemple #16
0
 public static MutableString Matched(StringScanner/*!*/ self)
 {
     if (self.LastMatch == null) {
         return null;
     }
     return MutableString.Create(self.LastMatch);
 }
Exemple #17
0
 public static MutableString Peek(StringScanner/*!*/ self, int len)
 {
     if (len < 0) {
         throw RubyExceptions.CreateArgumentError("negative string size (or size too big)");
     }
     int maxlen = self.Length - self.CurrentPosition;
     if (len > maxlen) {
         len = maxlen;
     }
     if (self.CurrentPosition >= self.Length || len == 0) {
         return MutableString.CreateEmpty();
     }
     return self.ScanString.GetSlice(self.CurrentPosition, len);
 }
Exemple #18
0
 public static int GetCurrentPosition(StringScanner /*!*/ self)
 {
     return(self.CurrentPosition);
 }
Exemple #19
0
 public static StringScanner Reset(StringScanner/*!*/ self)
 {
     self.Reset();
     return self;
 }
Exemple #20
0
 public static StringScanner Reset(StringScanner /*!*/ self)
 {
     self.Reset();
     return(self);
 }
Exemple #21
0
 public static object ScanUntil(StringScanner/*!*/ self, [NotNull]RubyRegex/*!*/ pattern)
 {
     return SearchFull(self, pattern, true, true);
 }
Exemple #22
0
 public static bool IsRestLeft(StringScanner /*!*/ self)
 {
     return(self.CurrentPosition < self.Length);
 }
Exemple #23
0
 public static int? SkipUntil(StringScanner/*!*/ self, [NotNull]RubyRegex/*!*/ pattern)
 {
     bool match = self.Match(pattern, false, true);
     if (!match) {
         return null;
     }
     return (self.CurrentPosition - self.PreviousPosition);
 }
Exemple #24
0
 public static int RestSize(StringScanner /*!*/ self)
 {
     return((self.CurrentPosition < self.Length) ? (self.Length - self.CurrentPosition) : 0);
 }
Exemple #25
0
 public static MutableString Scan(StringScanner /*!*/ self, [NotNull] RubyRegex /*!*/ pattern)
 {
     return(ScanFull(self, pattern, true, true) as MutableString);
 }
Exemple #26
0
 public static object /*!*/ Scan(StringScanner /*!*/ self, [NotNull] RubyRegex /*!*/ pattern)
 {
     return(ScanFull(self, pattern, true, true));
 }
Exemple #27
0
 public static MutableString GetMatchSubgroup(StringScanner/*!*/ self, int subgroup)
 {
     if (subgroup == 0 && self.LastMatch != null) {
         return MutableString.Create(self.LastMatch);
     }
     if (self.LastMatchingGroups == null) {
         return null;
     }
     if (subgroup < 0) {
         subgroup = self.LastMatchingGroups.GroupCount - subgroup;
     }
     if (subgroup >= self.LastMatchingGroups.GroupCount) {
         return null;
     }
     return self.LastMatchingGroups.GetGroupValue(subgroup);
 }
Exemple #28
0
 public static object ScanUntil(StringScanner /*!*/ self, [NotNull] RubyRegex /*!*/ pattern)
 {
     return(SearchFull(self, pattern, true, true));
 }
Exemple #29
0
 public static void InitializeFrom(StringScanner/*!*/ self, [DefaultProtocol, NotNull]StringScanner/*!*/ other)
 {
     self.InitializeFrom(other);
 }
Exemple #30
0
 public static MutableString GetString(StringScanner /*!*/ self)
 {
     return(self.ScanString);
 }
Exemple #31
0
 public static int? Match(StringScanner/*!*/ self, [NotNull]RubyRegex/*!*/ pattern)
 {
     if (!self.Match(pattern, true, false)) {
         return null;
     }
     return self.LastMatch.GetLength();
 }
Exemple #32
0
 public static MutableString SetString(RubyContext /*!*/ context, StringScanner /*!*/ self, [NotNull] MutableString /*!*/ str)
 {
     self.ScanString = (MutableString)KernelOps.Freeze(context, MutableString.Create(str));
     self.Reset();
     return(str);
 }
Exemple #33
0
 public static int? MatchedSize(StringScanner/*!*/ self)
 {
     if (self.LastMatch == null) {
         return null;
     }
     return self.LastMatch.Length;
 }
Exemple #34
0
 public static StringScanner Clear(StringScanner /*!*/ self)
 {
     self.Reset();
     self.CurrentPosition = self.Length;
     return(self);
 }
Exemple #35
0
 public static MutableString PostMatch(StringScanner/*!*/ self)
 {
     if (self.LastMatch == null) {
         return null;
     }
     int position = self.FoundPosition + self.LastMatch.Length;
     int len = self.Length - position;
     if (len <= 0) {
         return MutableString.CreateEmpty();
     }
     return self.ScanString.GetSlice(position, len);
 }
Exemple #36
0
 public static void Reinitialize(StringScanner /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ scan, [Optional] object ignored)
 {
     self.ScanString = scan;
     self.Reset();
 }
Exemple #37
0
 public static void Reinitialize(StringScanner/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ scan, [Optional]object ignored)
 {
     self.ScanString = scan;
     self.Reset();
 }
Exemple #38
0
 public static void InitializeFrom(StringScanner /*!*/ self, [DefaultProtocol, NotNull] StringScanner /*!*/ other)
 {
     self.InitializeFrom(other);
 }
Exemple #39
0
 public static MutableString Rest(StringScanner/*!*/ self)
 {
     int len = self.Length - self.CurrentPosition;
     if (len <= 0) {
         return MutableString.CreateEmpty();
     }
     return self.ScanString.GetSlice(self.CurrentPosition, len);
 }
Exemple #40
0
 public static StringScanner Concat(StringScanner/*!*/ self, MutableString str)
 {
     self.ScanString.Append(str);
     return self;
 }
Exemple #41
0
 public static object ScanFull(StringScanner/*!*/ self, [NotNull]RubyRegex/*!*/ pattern, bool advancePointer, bool returnString)
 {
     bool match = self.Match(pattern, true, advancePointer);
     if (match) {
         if (returnString) {
             return MutableString.Create(self.LastMatch);
         } else {
             return ScriptingRuntimeHelpers.Int32ToObject(self.LastMatch.Length);
         }
     }
     return null;
 }
Exemple #42
0
 public static StringScanner Create(RubyClass/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ scan, [Optional]object ignored)
 {
     var result = new StringScanner(self);
     result.ScanString = scan;
     result.Reset();
     return result;
 }
Exemple #43
0
 public static object SearchFull(StringScanner/*!*/ self, [NotNull]RubyRegex/*!*/ pattern, bool advancePointer, bool returnString)
 {
     bool match = self.Match(pattern, false, advancePointer);
     if (match) {
         int length = self.LastMatch.Length + (self.FoundPosition - self.PreviousPosition);
         if (returnString) {
             return self.ScanString.GetSlice(self.PreviousPosition, length);
         } else {
             return ScriptingRuntimeHelpers.Int32ToObject(length);
         }
     }
     return null;
 }
Exemple #44
0
 public static bool EndOfLine(StringScanner/*!*/ self)
 {
     return self.CurrentPosition >= self.Length;
 }
Exemple #45
0
 public static MutableString SetString(RubyContext/*!*/ context, StringScanner/*!*/ self, [NotNull]MutableString/*!*/ str)
 {
     self.ScanString = (MutableString)KernelOps.Freeze(context, MutableString.Create(str));
     self.Reset();
     return str;
 }
Exemple #46
0
 public static int? Exist(StringScanner/*!*/ self, [NotNull]RubyRegex/*!*/ pattern)
 {
     if (!self.Match(pattern, false, false)) {
         return null;
     }
     return self.FoundPosition + self.LastMatch.Length;
 }
Exemple #47
0
 public static MutableString ToString(StringScanner/*!*/ self)
 {
     return MutableString.Create(self.ToString(), self._scanString.Encoding);
 }
Exemple #48
0
 public static MutableString GetChar(StringScanner/*!*/ self)
 {
     if (self.CurrentPosition >= self.Length) {
         return null;
     }
     self.PreviousPosition = self.CurrentPosition;
     self.FoundPosition = self.CurrentPosition;
     self.LastMatch = self.ScanString.GetSlice(self.CurrentPosition++, 1);
     return MutableString.Create(self.LastMatch);
 }
Exemple #49
0
 public static bool WasMatched(StringScanner/*!*/ self)
 {
     return (self.LastMatch != null);
 }
Exemple #50
0
 public static MutableString ToString(StringScanner /*!*/ self)
 {
     return(MutableString.Create(self.ToString()));
 }