public static CToken GetToken(TextStream cursor) { CToken result = PeekToken(cursor); if (result.Kind != CppTokenKind.Eof) { Debug.Assert(result.Length > 0); cursor.Seek(result.End); } return(result); }
public static CToken PeekToken(TextStream cursor) { TextPosition startPos = cursor.TextPosition; CToken token = PeekTokenRaw(cursor); do { if (token.Kind == CppTokenKind.Eof) { break; } if (!(token.Kind == CppTokenKind.Spacings || token.Kind == CppTokenKind.EndOfLine)) { break; } Debug.Assert(token.Length > 0); cursor.Seek(token.End); token = PeekTokenRaw(cursor); } while (!cursor.IsEOF); cursor.Seek(startPos); return(token); }