diff --git a/src/Pig.cpp b/src/Pig.cpp index 4ce78a08..94040aec 100644 --- a/src/Pig.cpp +++ b/src/Pig.cpp @@ -26,18 +26,43 @@ #include #include +#include #include #include //////////////////////////////////////////////////////////////////////////////// Pig::Pig (const std::string& text) : _text (text) -, _mark (std::string::npos) +, _mark (0) , _cursor (0) , _debug (false) { } +//////////////////////////////////////////////////////////////////////////////// +bool Pig::skipWS () +{ + int c; + auto prev = _cursor; + while ((c = utf8_next_char (_text, _cursor))) + { + if (! Lexer::isWhitespace (c)) + { + _cursor = prev; + break; + } + prev = _cursor; + } + + if (_cursor > _mark) + { + _mark = _cursor; + return true; + } + + return false; +} + //////////////////////////////////////////////////////////////////////////////// void Pig::debug (bool value) { diff --git a/src/Pig.h b/src/Pig.h index 732a07bd..1527fb83 100644 --- a/src/Pig.h +++ b/src/Pig.h @@ -34,6 +34,8 @@ class Pig public: Pig (const std::string&); + bool skipWS (); + void debug (bool); std::string dump () const;