MCPcopy Create free account
hub / github.com/GothenburgBitFactory/taskwarrior / isInteger

Method isInteger

src/Lexer.cpp:567–586  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Lexer::Type::number 0 [1-9]\d Integers do not start with a leading 0, unless they are zero.

Source from the content-addressed store, hash-verified

565// [1-9]\d*
566// Integers do not start with a leading 0, unless they are zero.
567bool Lexer::isInteger(std::string& token, Lexer::Type& type) {
568 std::size_t marker = _cursor;
569
570 bool leading_zero = (_text[marker] == '0');
571
572 if (unicodeLatinDigit(_text[marker])) {
573 ++marker;
574 while (unicodeLatinDigit(_text[marker])) utf8_next_char(_text, marker);
575
576 // Leading zero is only allowed in the case of number 0
577 if (leading_zero and marker - _cursor > 1) return false;
578
579 token = _text.substr(_cursor, marker - _cursor);
580 type = Lexer::Type::number;
581 _cursor = marker;
582 return true;
583 }
584
585 return false;
586}
587
588////////////////////////////////////////////////////////////////////////////////
589// Lexer::Type::separator

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected