예제 #1
0
 private object _append(INakoFuncCallInfo info)
 {
     object ary = info.StackPop(); // 参照渡しなので変数への参照が得られる
     object s   = info.StackPop();
     if (!(ary is NakoVariable))
     {
         throw new NakoPluginRuntimeException("『追加』の引数がvariableではありません");
     }
     NakoVariable ary_link = (NakoVariable)ary;
     if (ary_link.Body is NakoVarArray)
     {
         NakoVarArray arr = (NakoVarArray)ary_link.Body;
         NakoVariable new_item = new NakoVariable();
         new_item.SetBodyAutoType(s);
         arr.Add(new_item);
     }else if(ary_link.Body is string && (string)ary_link.Body==""){
         NakoVarArray arr = new NakoVarArray();
         NakoVariable new_item = new NakoVariable();
         new_item.SetBodyAutoType(s);
         arr.Add(new_item);
         ary_link.SetBody(arr,NakoVarType.Array);
     }
     // 結果をセット
     return null;
 }
예제 #2
0
 public Object _matchAll(INakoFuncCallInfo info)
 {
     string s = info.StackPopAsString();
     string pattern = info.StackPopAsString();
     m = Regex.Match(s,pattern);
     NakoVarArray res = info.CreateArray();
     int index = 0;
     NakoVarArray groups = new NakoVarArray();
     //        	NakoVariable ret = new NakoVariable();
     while(m.Success){
         res.SetValue(index,m.Value);
         NakoVarArray subgroups = new NakoVarArray();
         for (int i = 0; i < m.Groups.Count; i++)
         {
             subgroups.SetValue(i,m.Groups[i].Value);
         }
         groups.Add(subgroups);
     //        	    for(int i = 0;i < m.Groups.Count;i++){
     //        	        groups.SetValue(i,m.Groups[i].Value);
     //        	    }
     //        	    ret.Type = NakoVarType.Array;
     //        	    ret.Body = groups;
         index++;
         m = m.NextMatch();
     }
     info.SetVariableValue("抽出文字列", groups);
      	    return res;
 }