mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Pig: Added ::skipWS
This commit is contained in:
parent
26693a50b5
commit
b382bcba1e
2 changed files with 28 additions and 1 deletions
27
src/Pig.cpp
27
src/Pig.cpp
|
@ -26,18 +26,43 @@
|
|||
|
||||
#include <cmake.h>
|
||||
#include <Pig.h>
|
||||
#include <Lexer.h>
|
||||
#include <utf8.h>
|
||||
#include <sstream>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -34,6 +34,8 @@ class Pig
|
|||
public:
|
||||
Pig (const std::string&);
|
||||
|
||||
bool skipWS ();
|
||||
|
||||
void debug (bool);
|
||||
std::string dump () const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue