void Skip_Comment(wxInputStream &stream) { wxTextInputStream text_stream(stream); if (stream.Peek()==wxT('#')) { text_stream.ReadLine(); Skip_Comment(stream); } }
static void SkipWhitespace(wxInputStream& input, unsigned int& lineNumber) { char c; while (!input.Eof()) { c = input.Peek(); if (c == '\n') { ++lineNumber; } else if (c == '-') { input.GetC(); char c2 = input.Peek(); if (c2 == '-') { // Lua single line comment. while (!input.Eof() && input.GetC() != '\n') { } ++lineNumber; continue; } } else if (c == '/') { input.GetC(); char c2 = input.Peek(); if (c2 == '*') { // C++ block comment. input.GetC(); while (!input.Eof()) { c = input.GetC(); if (c == '\n') { ++lineNumber; } if (c == '*' && input.Peek() == '/') { input.GetC(); break; } } continue; } else if (c2 == '/') { // C++ single line comment. while (!input.Eof() && input.GetC() != '\n') { } ++lineNumber; continue; } else { input.Ungetch(c); break; } } if (!IsSpace(c)) { break; } input.GetC(); } }
bool GetToken(wxInputStream& input, wxString& result, unsigned int& lineNumber) { result.Empty(); SkipWhitespace(input, lineNumber); // Reached the end of the file. if (input.Eof()) { return false; } char c = input.GetC(); if (c == '\"') { // Quoted string, search for the end quote. do { result += c; c = input.GetC(); } while (input.IsOk() && c != '\"'); result += c; return true; } char n = input.Peek(); if (IsDigit(c) || (c == '.' && IsDigit(n)) || (c == '-' && IsDigit(n))) { bool hasDecimal = false; while (!IsSpace(c)) { result.Append(c); if (input.Eof()) { return true; } c = input.Peek(); if (!IsDigit(c) && c != '.') { return true; } input.GetC(); if (c == '\n') { ++lineNumber; return true; } } } else { if (IsSymbol(c)) { result = c; return true; } while (!IsSpace(c) && !input.Eof()) { result.Append(c); if (IsSymbol(input.Peek())) { break; } c = input.GetC(); if (c == '\n') { ++lineNumber; return true; } } } return true; }