/// <summary> /// Reads the tab count for the line /// </summary> private void ReadTabs(TbonContext context) { int spaces = 0; int peek; while (true) { peek = context.Peek(); if (peek == -1) { context.tabs = -1; return; } if ((char)peek == '\t') { spaces += 4; } else if ((char)peek == ' ') { spaces++; } else { break; } context.Read(); } context.tabs += (spaces + 3) / 4; }
private void ReadUntil(TbonContext context, out string value, out char stopped, params char[] stopChars) { int charCount = 0; char character; value = null; stopped = '\0'; while (true) { int read = context.Peek(); if (read == -1) { stopped = '\0'; if (charCount == 0) { return; } value = new string(context.characterBuffer, 0, charCount); return; } character = context.Read(); if (TryCharsContain(stopChars, character, out stopped)) { if (charCount == 0) { return; } value = new string(context.characterBuffer, 0, charCount); return; } else { context.characterBuffer[charCount] = character; } charCount++; } }