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

Method isSet

src/Lexer.cpp:673–706  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Lexer::Type::set a single number: 1 a list of numbers: 1,3,5 a range: 5-10 or a combination: 1,3,5-10 [ - ] [ , [ - ] ] ...

Source from the content-addressed store, hash-verified

671//
672// <id> [ - <id> ] [ , <id> [ - <id> ] ] ...
673bool Lexer::isSet(std::string& token, Lexer::Type& type) {
674 std::size_t marker = _cursor;
675 int count = 0;
676 std::string dummyToken;
677 Lexer::Type dummyType;
678
679 do {
680 if (isInteger(dummyToken, dummyType)) {
681 ++count;
682 if (isLiteral("-", false, false)) {
683 if (isInteger(dummyToken, dummyType))
684 ++count;
685 else {
686 _cursor = marker;
687 return false;
688 }
689 }
690 } else {
691 _cursor = marker;
692 return false;
693 }
694 } while (isLiteral(",", false, false));
695
696 // Success is multiple numbers, matching the pattern.
697 if (count > 1 && (isEOS() || unicodeWhitespace(_text[_cursor]) ||
698 isHardBoundary(_text[_cursor], _text[_cursor + 1]))) {
699 token = _text.substr(marker, _cursor - marker);
700 type = Lexer::Type::set;
701 return true;
702 }
703
704 _cursor = marker;
705 return false;
706}
707
708////////////////////////////////////////////////////////////////////////////////
709// Lexer::Type::tag

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected