diff --git a/src/Pig.cpp b/src/Pig.cpp index 8c4e9931..6fb93942 100644 --- a/src/Pig.cpp +++ b/src/Pig.cpp @@ -63,6 +63,21 @@ bool Pig::skipWS () return false; } +//////////////////////////////////////////////////////////////////////////////// +bool Pig::getDigit (int& result) +{ + int c = _text[_cursor]; + if (Lexer::isDigit (c)) + { + result = c - '0'; + ++_cursor; + ++_mark; + return true; + } + + return false; +} + //////////////////////////////////////////////////////////////////////////////// void Pig::debug (bool value) { diff --git a/src/Pig.h b/src/Pig.h index 1527fb83..67bf6472 100644 --- a/src/Pig.h +++ b/src/Pig.h @@ -36,6 +36,8 @@ public: bool skipWS (); + bool getDigit (int&); + void debug (bool); std::string dump () const;