Inheritance: IronRuby.Builtins.RubyObject
Exemplo n.º 1
0
 private void InitializeFrom(StringScanner/*!*/ other) {
     _currentPosition = other._currentPosition;
     _foundPosition = other._foundPosition;
     _lastMatch = other._lastMatch;
     _lastMatchingGroups = other._lastMatchingGroups;
     _previousPosition = other._previousPosition;
     _scanString = other.ScanString;
 }
Exemplo n.º 2
0
 public static bool IsRestLeft(StringScanner/*!*/ self)
 {
     return self.CurrentPosition < self.Length;
 }
Exemplo n.º 3
0
 public static MutableString GetString(StringScanner/*!*/ self)
 {
     return self.ScanString;
 }
Exemplo n.º 4
0
 public static int GetCurrentPosition(StringScanner/*!*/ self)
 {
     return self.CurrentPosition;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 7
0
 public static int RestSize(StringScanner/*!*/ self)
 {
     return (self.CurrentPosition < self.Length) ? (self.Length - self.CurrentPosition) : 0;
 }
Exemplo n.º 8
0
 public static MutableString PreMatch(StringScanner/*!*/ self)
 {
     if (self.LastMatch == null) {
         return null;
     }
     return self.ScanString.GetSlice(0, self.FoundPosition);
 }
Exemplo n.º 9
0
 public static bool WasMatched(StringScanner /*!*/ self)
 {
     return(self.LastMatch != null);
 }
Exemplo n.º 10
0
 public static MutableString ToString(StringScanner /*!*/ self)
 {
     return(MutableString.Create(self.ToString(), self._scanString.Encoding));
 }
Exemplo n.º 11
0
 public static bool EndOfLine(StringScanner /*!*/ self)
 {
     return(self.CurrentPosition >= self.Length);
 }
Exemplo n.º 12
0
 public static MutableString CheckUntil(StringScanner /*!*/ self, [NotNull] RubyRegex /*!*/ pattern)
 {
     return(SearchFull(self, pattern, false, true) as MutableString);
 }
Exemplo n.º 13
0
 public static bool BeginningOfLine(StringScanner /*!*/ self)
 {
     return((self.CurrentPosition == 0) || (self.ScanString.GetChar(self.CurrentPosition - 1) == '\n'));
 }
Exemplo n.º 14
0
 public static StringScanner Concat(StringScanner /*!*/ self, MutableString str)
 {
     self.ScanString.Append(str);
     return(self);
 }
Exemplo n.º 15
0
 public static void Reinitialize(StringScanner /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ scan)
 {
     self.ScanString = scan;
     self.Reset();
 }
Exemplo n.º 16
0
 public static MutableString Matched(StringScanner/*!*/ self)
 {
     if (self.LastMatch == null) {
         return null;
     }
     return MutableString.Create(self.LastMatch);
 }
Exemplo n.º 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);
 }
Exemplo n.º 18
0
 public static int GetCurrentPosition(StringScanner /*!*/ self)
 {
     return(self.CurrentPosition);
 }
Exemplo n.º 19
0
 public static StringScanner Reset(StringScanner/*!*/ self)
 {
     self.Reset();
     return self;
 }
Exemplo n.º 20
0
 public static StringScanner Reset(StringScanner /*!*/ self)
 {
     self.Reset();
     return(self);
 }
Exemplo n.º 21
0
 public static object ScanUntil(StringScanner/*!*/ self, [NotNull]RubyRegex/*!*/ pattern)
 {
     return SearchFull(self, pattern, true, true);
 }
Exemplo n.º 22
0
 public static bool IsRestLeft(StringScanner /*!*/ self)
 {
     return(self.CurrentPosition < self.Length);
 }
Exemplo n.º 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);
 }
Exemplo n.º 24
0
 public static int RestSize(StringScanner /*!*/ self)
 {
     return((self.CurrentPosition < self.Length) ? (self.Length - self.CurrentPosition) : 0);
 }
Exemplo n.º 25
0
 public static MutableString Scan(StringScanner /*!*/ self, [NotNull] RubyRegex /*!*/ pattern)
 {
     return(ScanFull(self, pattern, true, true) as MutableString);
 }
Exemplo n.º 26
0
 public static object /*!*/ Scan(StringScanner /*!*/ self, [NotNull] RubyRegex /*!*/ pattern)
 {
     return(ScanFull(self, pattern, true, true));
 }
Exemplo n.º 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);
 }
Exemplo n.º 28
0
 public static object ScanUntil(StringScanner /*!*/ self, [NotNull] RubyRegex /*!*/ pattern)
 {
     return(SearchFull(self, pattern, true, true));
 }
Exemplo n.º 29
0
 public static void InitializeFrom(StringScanner/*!*/ self, [DefaultProtocol, NotNull]StringScanner/*!*/ other)
 {
     self.InitializeFrom(other);
 }
Exemplo n.º 30
0
 public static MutableString GetString(StringScanner /*!*/ self)
 {
     return(self.ScanString);
 }
Exemplo n.º 31
0
 public static int? Match(StringScanner/*!*/ self, [NotNull]RubyRegex/*!*/ pattern)
 {
     if (!self.Match(pattern, true, false)) {
         return null;
     }
     return self.LastMatch.GetLength();
 }
Exemplo n.º 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);
 }
Exemplo n.º 33
0
 public static int? MatchedSize(StringScanner/*!*/ self)
 {
     if (self.LastMatch == null) {
         return null;
     }
     return self.LastMatch.Length;
 }
Exemplo n.º 34
0
 public static StringScanner Clear(StringScanner /*!*/ self)
 {
     self.Reset();
     self.CurrentPosition = self.Length;
     return(self);
 }
Exemplo n.º 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);
 }
Exemplo n.º 36
0
 public static void Reinitialize(StringScanner /*!*/ self, [DefaultProtocol, NotNull] MutableString /*!*/ scan, [Optional] object ignored)
 {
     self.ScanString = scan;
     self.Reset();
 }
Exemplo n.º 37
0
 public static void Reinitialize(StringScanner/*!*/ self, [DefaultProtocol, NotNull]MutableString/*!*/ scan, [Optional]object ignored)
 {
     self.ScanString = scan;
     self.Reset();
 }
Exemplo n.º 38
0
 public static void InitializeFrom(StringScanner /*!*/ self, [DefaultProtocol, NotNull] StringScanner /*!*/ other)
 {
     self.InitializeFrom(other);
 }
Exemplo n.º 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);
 }
Exemplo n.º 40
0
 public static StringScanner Concat(StringScanner/*!*/ self, MutableString str)
 {
     self.ScanString.Append(str);
     return self;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 44
0
 public static bool EndOfLine(StringScanner/*!*/ self)
 {
     return self.CurrentPosition >= self.Length;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 47
0
 public static MutableString ToString(StringScanner/*!*/ self)
 {
     return MutableString.Create(self.ToString(), self._scanString.Encoding);
 }
Exemplo n.º 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);
 }
Exemplo n.º 49
0
 public static bool WasMatched(StringScanner/*!*/ self)
 {
     return (self.LastMatch != null);
 }
Exemplo n.º 50
0
 public static MutableString ToString(StringScanner /*!*/ self)
 {
     return(MutableString.Create(self.ToString()));
 }