Inheritance: MatchResult
Exemplo n.º 1
0
 public static int ReplaceFirst(Matcher m,Substitution substitution,TextWriter _out)
 {
     try {
         return ReplaceFirst(m,substitution,Wrap(_out));
     } catch(WriteException e) {
         throw e.reason;
     }
 }
Exemplo n.º 2
0
 public static int ReplaceFirst(Matcher m,Substitution substitution,TextBuffer dest)
 {
     int c=0;
     if(m.Find()) {
         if(m.Start>0) m.Group(Matcher.PREFIX,dest);
         substitution.AppendSubstitution(m,dest);
         c++;
         m.SetTarget(m,Matcher.SUFFIX);
     }
     m.Group(Matcher.TARGET,dest);
     return c;
 }
Exemplo n.º 3
0
 public static int Replace(Matcher m,Substitution substitution,TextBuffer dest)
 {
     bool firstPass=true;
     int c=0;
     while(m.Find()) {
         if(m.End==0 && !firstPass) continue;  //allow to Replace at "^"
         if(m.Start>0) m.Group(Matcher.PREFIX,dest);
         substitution.AppendSubstitution(m,dest);
         c++;
         m.SetTarget(m,Matcher.SUFFIX);
         firstPass=false;
     }
     m.Group(Matcher.TARGET,dest);
     return c;
 }
Exemplo n.º 4
0
 static Element MakeQueue(Matcher refMatcher)
 {
     if(refMatcher.Find()){
         Element element;
         if(refMatcher.IsCaptured(NAME_ID)){
             char c=refMatcher.CharAt(0,NAME_ID);
             if(c=='&') {
                 element = new IntRefHandler(refMatcher.Prefix, 0);
             } else if(char.IsDigit(c)){
                 element = new IntRefHandler(refMatcher.Prefix, Convert.ToInt32(refMatcher.Group(NAME_ID)));
             } else
                 element = new StringRefHandler(refMatcher.Prefix, refMatcher.Group(NAME_ID));
         } else {
             //escaped char
             element = new PlainElement(refMatcher.Prefix, refMatcher.Group(ESC_ID));
         }
         refMatcher.SetTarget(refMatcher, Matcher.SUFFIX);
         element.next = MakeQueue(refMatcher);
         return element;
     } else return new PlainElement(refMatcher.Target);
 }
Exemplo n.º 5
0
 public Matcher Matcher(TextReader text, int length)
 {
     Matcher m = new Matcher(this);
     m.SetTarget(text, length);
     return m;
 }
Exemplo n.º 6
0
 public Matcher Matcher(MatchResult res, int groupId)
 {
     Matcher m = new Matcher(this);
     if(res is Matcher){
         m.SetTarget((Matcher)res, groupId);
     } else{
         m.SetTarget(res.TargetChars, res.GetStart(groupId)+res.TargetStart, res.GetLength(groupId));
     }
     return m;
 }
Exemplo n.º 7
0
 public Matcher Matcher(char[] data, int start, int end)
 {
     Matcher m = new Matcher(this);
     m.SetTarget(data, start, end);
     return m;
 }
Exemplo n.º 8
0
 public Matcher Matcher(string s)
 {
     Matcher m = new Matcher(this);
     m.Target = s;
     return m;
 }
Exemplo n.º 9
0
 public void SetTarget(Matcher m, int groupId)
 {
     MemReg mr=m.Bounds(groupId);
     if(mr==null) throw new ArgumentException("group #"+groupId+" is not assigned");
     data=m.data;
     offset=mr._in;
     end=mr._out;
     cache=m.cache;
     cacheLength=m.cacheLength;
     cacheOffset=m.cacheOffset;
     if(m!=this){
         shared=true;
         m.shared=true;
     }
     Init();
 }
Exemplo n.º 10
0
 public SimpleMatchIterator(Matcher matcher, int options)
 {
     this.matcher = matcher;
     this.options = options;
 }
Exemplo n.º 11
0
 public PerlSubstitution(string s)
 {
     Matcher refMatcher = new Matcher(refPtn);
     refMatcher.Target = s;
     queueEntry = MakeQueue(refMatcher);
 }