public Dictionary<String, String> Read(CharEnumerator ci, String endpoint) { ct = ci; NextChar(); ReadJson(endpoint); return map; }
// groups the characters into string for a given element // or a line in the file public void stringtok(CharEnumerator c){ string s = null; SpecialCharacterReader Scr = new SpecialCharacterReader(); Storage cont = new Storage(); while(c.MoveNext()){ CharEnumerator Cnum2 = (CharEnumerator)c.Clone(); current = c.Current; if(Cnum2.MoveNext()){ next = Cnum2.Current; string sp = Scr.Special(current, next); if(sp != null){ s += sp; c.MoveNext(); } else { s += c.Current.ToString(); } } } if(next == '\0'){ s += current.ToString(); if(s != "\0") cont.setContainer1(s); } else { s += next.ToString(); if(s != "\0") cont.setContainer1(s); } }
internal Dev2Tokenizer(string candiateString, IList<IDev2SplitOp> ops, bool reversed) { // only build if we are using a non-single token op set ;) _ops = ops; _isReversed = reversed; _useEnumerator = CanUseEnumerator(); _masterLen = candiateString.Length; // we need the char array :( - non optimized if (!_useEnumerator) { _tokenParts = candiateString.ToCharArray(); } else { _charEnumerator = candiateString.GetEnumerator(); } _opPointer = 0; _hasMoreOps = true; if (!_isReversed) { _startIdx = 0; } else { _startIdx = _tokenParts.Length - 1; } }
public void SetDataAsMString(string[] arr, int Length) { m_DataSize = (Length + arr.Length) * 2; m_Data = new byte[m_DataSize]; long l = 0; foreach (string elem in arr) { if (string.IsNullOrEmpty(elem)) { continue; } System.CharEnumerator ce = elem.GetEnumerator(); while (ce.MoveNext()) { m_Data[l] = (byte)(ce.Current & 0xFF); l++; m_Data[l] = (byte)(ce.Current >> 8); l++; } m_Data[l] = 0; l++; m_Data[l] = 0; l++; } }
private bool SkipSpace(CharEnumerator iter) { while(IsSplit(iter.Current)) { if (!iter.MoveNext()) return false; } return true; }
public void Init(string _sourceText, int _writeCharCountPerCall) { sourceText = _sourceText; writeCharCountPerCall = _writeCharCountPerCall; charEnum = sourceText.GetEnumerator(); sb = new StringBuilder(); initialized = true; isWriteOver = false; moveNextFail = false; }
private string GetFromEnumerator (CharEnumerator ce) { string res = ""; bool cont = true; while (cont) { res += ce.Current; cont = ce.MoveNext (); } return res; }
public void SetDataAsString(string val) { m_DataSize = val.Length * 2; m_Data = new byte[m_DataSize]; System.CharEnumerator ce = val.GetEnumerator(); long l = 0; while (ce.MoveNext()) { m_Data[l] = (byte)(ce.Current & 0xFF); l++; m_Data[l] = (byte)(ce.Current >> 8); l++; } }
protected override void loadQuestion() { charEnumerator = CurrentQuestion.getInstance().Question.GetEnumerator(); questionControl = new TextBlock(); questionControl.MaxWidth = 1000; questionControl.TextWrapping = System.Windows.TextWrapping.Wrap; questionControl.Text = "Q) "; questionControl.FontSize = 50; pageStack.Children.Add(questionControl); // Convert the duration to miliseconds, then divide by the number of characters in the question timer = new Timer(); timer.Interval = Properties.Settings.Default.duration * 1000 / CurrentQuestion.getInstance().Question.Length; timer.Elapsed += timer_Elapsed; }
static StackObject *MoveNext_1(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.CharEnumerator instance_of_this_method = (System.CharEnumerator) typeof(System.CharEnumerator).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = instance_of_this_method.MoveNext(); __ret->ObjectType = ObjectTypes.Integer; __ret->Value = result_of_this_method ? 1 : 0; return(__ret + 1); }
// Removes the comments from the input code public string CommentRemover(CharEnumerator c){ int flag = 0; while(c.MoveNext()){ CharEnumerator Cnum2 = (CharEnumerator)c.Clone(); char current = c.Current; char next; if(Cnum2.MoveNext()){ next = Cnum2.Current; if(current.ToString() == "\"" && next.ToString() == "/"){ flag = 1; } if((current.ToString() == "/" && next.ToString() == "/") || (current.ToString() == "/" && next.ToString() == "*") && flag == 0){ while (c.MoveNext()){ s += c.Current.ToString(); } if (s == null){ return null; } } } } return s; }
private bool Parse(CharEnumerator experIter, IOperator prevOp, out IOperator op) { if (!SkipSpace(experIter)) { op = null; return true; } bool isEof = false; char curCh = experIter.Current; switch (curCh) { case '-': isEof = ParseSub(experIter, prevOp, out op); break; case '+': break; default: op = null; break; } op = null; return isEof; }
string Parse(CharEnumerator e, string name = null) { return ParseMethod (e, name) ?? ParsePrimitive (e, name) ?? ParseArray (e, name) ?? ParseClass (e, name); }
string ParsePrimitive(CharEnumerator e, string name = null) { string type; switch (e.Current) { case 'V': type = "void"; break; case 'Z': type = "boolean"; break; case 'B': type = "byte"; break; case 'C': type = "char"; break; case 'S': type = "short"; break; case 'I': type = "int"; break; case 'J': type = "long"; break; case 'F': type = "float"; break; case 'D': type = "double"; break; default: return null; } if (name == null) return type; return String.Concat (type, " ", name); }
string ParseMethod(CharEnumerator e, string name = null) { if (e.Current != '(') return null; List<string> args = new List<string> (); if (!e.MoveNext ()) throw new FormatException (); while (e.Current != ')') { args.Add (Parse (e)); if (!e.MoveNext ()) throw new FormatException (); } if (!e.MoveNext ()) throw new FormatException (); var returnType = Parse (e); var sb = new StringBuilder (); if (returnType != "void" || name != "<init>") { sb.Append (returnType); sb.Append (' '); } if (name != null) { sb.Append (name); } sb.Append ("("); sb.Append (String.Join (", ", args)); sb.Append (")"); return sb.ToString (); }
string ParseClass(CharEnumerator e, string name = null) { if (e.Current != 'L') return null; var sb = new StringBuilder (); if (!e.MoveNext ()) throw new FormatException (); while (e.Current != ';') { sb.Append (e.Current == '/' ? '.' : e.Current); if (!e.MoveNext ()) throw new FormatException (); } if (name != null) { sb.Append (' '); sb.Append (name); } return sb.ToString (); }
private static void RegCh(CharEnumerator charEnum, string regex, List<KeyValuePair<string, string[]>> parsed) { if (charEnum.Current == '\\') // begins an escaped character { charEnum.MoveNext(); if (charEnum.Current == 'x') // a number in octal hex: "\x99" { throw new NotImplementedException("Octal hex characters following the pattern \"\\x99\" are not yet implemented."); } else if (patterns.ContainsKey("\\" + charEnum.Current.ToString())) { parsed.Add(new KeyValuePair<string, string[]>(regex, patterns["\\" + charEnum.Current.ToString()])); } else { parsed.Add(new KeyValuePair<string,string[]>(regex, new string[] { charEnum.Current.ToString() })); } } if (charEnum.Current == '.') // any character { parsed.Add(new KeyValuePair<string, string[]>(regex, patterns[charEnum.Current.ToString()])); } if (charEnum.Current == '[') // begin a range: "[A-Z]" { int start = -1; while (charEnum.MoveNext() && charEnum.Current != ']') { if (charEnum.Current == '-' && start != -1) { int end = -1; charEnum.MoveNext(); if (start <= (int)charEnum.Current) { end = (int)charEnum.Current; } else { end = start; start = (int)charEnum.Current; } var charsInRange = new string[(end - start) + 1]; for (int i = 0; i <= (end - start); i++) charsInRange[i] = ((char)start + i).ToString(); parsed.Add(new KeyValuePair<string, string[]>(regex, charsInRange)); start = -1; } else { start = (int)charEnum.Current; } } if (charEnum.Current != ']') throw new InvalidOperationException("unmatched []"); } if (charEnum.Current == '*') // matches 0 or more times { } }
public string ExecuteOperation(CharEnumerator candidate, int startIdx, int len, bool isReversed) { throw new NotImplementedException(); }
private void MakeValue(CharEnumerator format, int flags) { for (;;) { int n; switch (PopChar(format)) { case '(': n = CountFormat(format, ')'); MakeList(format, ')', n, flags); return; case '[': n = CountFormat(format, ']'); MakeList(format, ']', n, flags); return; case '{': n = CountFormat(format, '}'); MakeList(format, '}', n, flags); return; case 'b': case 'B': case 'h': case 'i': ArgumentTypes.Add(dtInt); return; case 'H': case 'I': ArgumentTypes.Add(dtUInt); return; case 'n': ArgumentTypes.Add(dtPySize); return; case 'l': ArgumentTypes.Add(dtLong); return; case 'k': ArgumentTypes.Add(dtULong); return; case 'L': ArgumentTypes.Add(dtLongLong); return; case 'K': ArgumentTypes.Add(dtULongLong); return; case 'u': ArgumentTypes.Add(ptrPyUnicode); if (format.Current == '#') { format.MoveNext(); if ((flags & FLAG_SIZE_T) != 0) ArgumentTypes.Add(dtPySize); else ArgumentTypes.Add(dtInt); } return; case 'f': case 'd': ArgumentTypes.Add(dtDouble); return; case 'D': ArgumentTypes.Add(ptrPyComplex); return; case 'c': ArgumentTypes.Add(dtInt); return; case 's': case 'z': ArgumentTypes.Add(ptrChar); if (format.Current == '#') { format.MoveNext(); if ((flags & FLAG_SIZE_T) != 0) ArgumentTypes.Add(dtPySize); else ArgumentTypes.Add(dtInt); } return; case 'N': case 'S': case 'O': if (format.Current == '&') { ArgumentTypes.Add(ptrPyConverter); ArgumentTypes.Add(ptrVoid); format.MoveNext(); } else ArgumentTypes.Add(ptrPyObject); return; case ':': case ',': case ' ': case '\t': break; default: throw new ApplicationException( "Bad format char passed to Py_BuildValue"); } } }
private int CountFormat(CharEnumerator format, int endchar) { format = (CharEnumerator)format.Clone(); int count = 0; int level = 0; while (level > 0 || format.Current != endchar) { switch (format.Current) { case '\0': /* Premature end */ throw new ApplicationException( "Unmatched paren in format"); case '(': case '[': case '{': if (level == 0) count++; level++; break; case ')': case ']': case '}': level--; break; case '#': case '&': case ',': case ':': case ' ': case '\t': break; default: if (level == 0) count++; break; } format.MoveNext(); } return count; }
private void ConvertTuple(CharEnumerator format, int flags) { int level = 0; int n = 0; var formatsave = format; format = (CharEnumerator)format.Clone(); for (;;) { var c = PopChar(format); if (c == '(') { if (level == 0) n++; level++; } else if (c == ')') { if (level == 0) break; level--; } else if (c == ':' || c == ';' || c == '\0') break; else if (level == 0 && char.IsLetter(c)) n++; } format = formatsave; for (int i = 0; i < n; i++) { ConvertItem(format, flags); } }
private byte[] FillFile(PolType type) { System.Collections.ArrayList arr = new System.Collections.ArrayList(); arr.Add(0x50); arr.Add(0x52); arr.Add(0x65); arr.Add(0x67); arr.Add(0x01); arr.Add(0x00); arr.Add(0x00); arr.Add(0x00); foreach (KeyValuePair <string, PolValue> val in GetVals(type)) { //foreach ( System.Collections.DictionaryEntry val in GetVals(type) ) { PolValue vl = (PolValue)(val.Value); arr.Add('['); arr.Add(0); // key System.CharEnumerator ce = vl.m_Key.GetEnumerator(); while (ce.MoveNext()) { arr.Add((ce.Current & 0xFF)); arr.Add((ce.Current >> 8)); } arr.Add(0); arr.Add(0); arr.Add(';'); arr.Add(0); // value ce = vl.m_Value.GetEnumerator(); while (ce.MoveNext()) { arr.Add((ce.Current & 0xFF)); arr.Add((ce.Current >> 8)); } arr.Add(0); arr.Add(0); arr.Add(';'); arr.Add(0); // type int l = (int)vl.m_KeyType; arr.Add((l & 0x000000FF)); arr.Add(((l >> 8) & 0x0000FFFF)); arr.Add(((l >> 16) & 0x00FFFFFF)); arr.Add((l >> 24)); arr.Add(';'); arr.Add(0); //size int data_size = vl.m_DataSize; if (vl.m_KeyType == KeyType.REG_SZ || vl.m_KeyType == KeyType.REG_EXPAND_SZ || vl.m_KeyType == KeyType.REG_MULTI_SZ) { data_size += 2; } l = data_size; arr.Add((l & 0x000000FF)); arr.Add(((l >> 8) & 0x0000FFFF)); arr.Add(((l >> 16) & 0x00FFFFFF)); arr.Add((l >> 24)); arr.Add(';'); arr.Add(0); for (int i = 0; i < vl.m_Data.Length; i++) { arr.Add(vl.m_Data[i]); } if (vl.m_KeyType == KeyType.REG_SZ || vl.m_KeyType == KeyType.REG_EXPAND_SZ || vl.m_KeyType == KeyType.REG_MULTI_SZ) { arr.Add(0); arr.Add(0); } arr.Add(']'); arr.Add(0); } byte[] res = new byte[arr.Count]; for (int i = 0; i < arr.Count; i++) { res[i] = System.Convert.ToByte(arr[i]); } return(res); }
// Methods public object Clone () { CharEnumerator x = new CharEnumerator (str); x.index = index; return x; }
string ParseArray(CharEnumerator e, string name = null) { if (e.Current != '[') return null; if (!e.MoveNext ()) throw new FormatException (); var type = Parse (e); if (name == null) return String.Concat (type, "[]"); return String.Concat (type, "[] ", name); }
public string ExecuteOperation(CharEnumerator canidate, int startIdx, int len, bool isReversed) { var result = new StringBuilder(); if (!isReversed && _tokenParts.Length == 1) { if (_tokenParts.Length == 1) { char tmp; // fetch next value while char previous = '\0'; while (canidate.MoveNext() && ((tmp = canidate.Current) != _tokenParts[0] || SkipDueToEscapeChar(previous))) { result.Append(tmp); previous = tmp; } } // did they want the token included? if (_include && (startIdx + result.Length) < len) { result.Append(_tokenParts); } } else { throw new Exception("CharEnumerator is not supported for this operation type!"); } return result.ToString(); }
/// <summary> Копировать объект из переданного </summary> /// <param name="copyFrom"> Объект, который копируется </param> private CharEnum(CharEnum copyFrom) { Index = copyFrom.Index; IsEnd = copyFrom.IsEnd; enumerator = (CharEnumerator)copyFrom.enumerator.Clone(); }
//------------------------------ // Use this for initialization void Start() { InvokeRepeating(theMethod, 0f, Interval); enemySpawnPattern = enemySpawnString.GetEnumerator(); }
private void ConvertItem(CharEnumerator format, int flags) { if (format.Current == '(') { format.MoveNext(); ConvertTuple(format, flags); format.MoveNext(); } else { ConvertSimple(format, flags); } }
private char PopChar(CharEnumerator e) { var current = e.Current; e.MoveNext(); return current; }
private void ConvertSimple(CharEnumerator format, int flags) { switch (PopChar(format)) { case 'b': /* unsigned byte -- very short int */ case 'B': /* byte sized bitfield - both signed and unsigned values allowed */ ArgumentTypes.Add(ptrChar); break; case 'h': /* signed short int */ ArgumentTypes.Add(Ptr(dtShort)); break; case 'H': /* short int sized bitfield, both signed and unsigned allowed */ ArgumentTypes.Add(Ptr(dtUShort)); break; case 'i': /* signed int */ ArgumentTypes.Add(Ptr(dtInt)); break; case 'I': /* int sized bitfield, both signed and unsigned allowed */ ArgumentTypes.Add(Ptr(dtUInt)); break; case 'n': /* Py_ssize_t */ ArgumentTypes.Add(Ptr(dtPySize)); break; case 'l': /* long int */ ArgumentTypes.Add(Ptr(dtLong)); break; case 'k': /* long sized bitfield */ ArgumentTypes.Add(Ptr(dtULong)); break; case 'L': /* PY_LONG_LONG */ ArgumentTypes.Add(Ptr(dtLongLong)); break; case 'K': /* long long sized bitfield */ ArgumentTypes.Add(Ptr(dtULongLong)); break; case 'f': /* float */ ArgumentTypes.Add(Ptr(dtFloat)); break; case 'd': /* double */ ArgumentTypes.Add(Ptr(dtDouble)); break; case 'D': /* complex double */ ArgumentTypes.Add(ptrPyComplex); break; case 'c': /* char */ ArgumentTypes.Add(ptrChar); break; case 's': /* string */ case 'z': /* string, may be NULL (None) */ if (format.Current == '*') { ArgumentTypes.Add(ptrPyBuffer); format.MoveNext(); } else if (format.Current == '#') { ArgumentTypes.Add(Ptr(ptrChar)); if ((flags & FLAG_SIZE_T) != 0) ArgumentTypes.Add(Ptr(dtPySize)); else ArgumentTypes.Add(Ptr(dtInt)); format.MoveNext(); } else { ArgumentTypes.Add(Ptr(ptrChar)); } break; case 'e': /* encoded string */ ArgumentTypes.Add(ptrChar); /* Get output buffer parameter: 's' (recode all objects via Unicode) or 't' (only recode non-string objects) */ if (format.Current != 's' && format.Current == 't') throw new ApplicationException( "Unknown parser marker combination"); ArgumentTypes.Add(Ptr(ptrChar)); format.MoveNext(); if (format.Current == '#') { /* Using buffer length parameter '#' */ if ((flags & FLAG_SIZE_T) != 0) ArgumentTypes.Add(Ptr(dtPySize)); else ArgumentTypes.Add(Ptr(dtInt)); format.MoveNext(); } break; case 'u': /* raw unicode buffer (Py_UNICODE *) */ if (format.Current == '#') { ArgumentTypes.Add(Ptr(ptrChar)); if ((flags & FLAG_SIZE_T) != 0) ArgumentTypes.Add(Ptr(dtPySize)); else ArgumentTypes.Add(Ptr(dtInt)); format.MoveNext(); } else { ArgumentTypes.Add(Ptr(ptrPyUnicode)); } break; case 'S': /* string object */ case 'U': /* Unicode object */ ArgumentTypes.Add(Ptr(ptrPyObject)); break; case 'O': /* object */ if (format.Current == '!') { ArgumentTypes.Add(ptrPyTypeObject); ArgumentTypes.Add(Ptr(ptrPyObject)); format.MoveNext(); } else if (format.Current == '?') { ArgumentTypes.Add(ptrPyInquiry); ArgumentTypes.Add(Ptr(ptrPyObject)); format.MoveNext(); } else if (format.Current == '&') { ArgumentTypes.Add(ptrPyConverter); ArgumentTypes.Add(ptrVoid); format.MoveNext(); } else { ArgumentTypes.Add(Ptr(ptrPyObject)); } break; case 'w': /* memory buffer, read-write access */ ArgumentTypes.Add(Ptr(ptrVoid)); if (format.Current == '*') { format.MoveNext(); } else if (format.Current == '#') { if ((flags & FLAG_SIZE_T) != 0) ArgumentTypes.Add(Ptr(dtPySize)); else ArgumentTypes.Add(Ptr(dtInt)); format.MoveNext(); } break; case 't': /* 8-bit character buffer, read-only access */ ArgumentTypes.Add(Ptr(ptrChar)); if (format.Current != '#') throw new ApplicationException( "Invalid use of 't' format character"); format.MoveNext(); if ((flags & FLAG_SIZE_T) != 0) ArgumentTypes.Add(Ptr(dtPySize)); else ArgumentTypes.Add(Ptr(dtInt)); break; default: throw new ApplicationException("Bad format char"); } }
private void MakeList( CharEnumerator format, int endchar, int n, int flags) { int i; for (i = 0; i < n; i++) MakeValue(format, flags); if (format.Current != endchar) throw new ApplicationException("Unmatched paren in format"); if (endchar != '\0') format.MoveNext(); }
public Lexer(string input) { inputEnumerator = input.GetEnumerator(); state = State.Start; tokenBuilder = new StringBuilder(); endOfInput = false; }
/// <summary> Создать объект для перебора символов </summary> /// <param name="str"> Строка, в которой перебираются символы </param> public CharEnum(string str) { enumerator = str.GetEnumerator(); Index = -1; IsEnd = false; }
public Context(string input) { _input = input; Iterator = input.GetEnumerator(); }
private static char Symbol(CharEnumerator chars) { while (chars.MoveNext()) { if (chars.Current == ';') { if (chars.MoveNext()) { char s = chars.Current; if (chars.MoveNext()) { if (chars.Current == '}') return s; throw new FormatException("The tolerance string representation is not well formatted"); } throw new FormatException("The tolerance string representation is not well formatted"); } throw new FormatException("The tolerance string representation is not well formatted"); } } throw new FormatException("The tolerance string representation is not well formatted"); }
public Parser(string input) { _s = input.GetEnumerator(); _next = _s.MoveNext(); Next(); }