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

Method isOperator

src/Lexer.cpp:819–880  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Lexer::Type::op _hastag_ | _notag | _neg_ | _pos_ | | | |

Source from the content-addressed store, hash-verified

817// <isDoubleCharOperator> |
818// <isSingleCharOperator> |
819bool Lexer::isOperator(std::string& token, Lexer::Type& type) {
820 std::size_t marker = _cursor;
821
822 if (_eos - marker >= 8 && _text.substr(marker, 8) == "_hastag_") {
823 marker += 8;
824 type = Lexer::Type::op;
825 token = _text.substr(_cursor, marker - _cursor);
826 _cursor = marker;
827 return true;
828 }
829
830 else if (_eos - marker >= 7 && _text.substr(marker, 7) == "_notag_") {
831 marker += 7;
832 type = Lexer::Type::op;
833 token = _text.substr(_cursor, marker - _cursor);
834 _cursor = marker;
835 return true;
836 }
837
838 else if (_eos - marker >= 5 && _text.substr(marker, 5) == "_neg_") {
839 marker += 5;
840 type = Lexer::Type::op;
841 token = _text.substr(_cursor, marker - _cursor);
842 _cursor = marker;
843 return true;
844 }
845
846 else if (_eos - marker >= 5 && _text.substr(marker, 5) == "_pos_") {
847 marker += 5;
848 type = Lexer::Type::op;
849 token = _text.substr(_cursor, marker - _cursor);
850 _cursor = marker;
851 return true;
852 }
853
854 else if (_eos - marker >= 3 && isTripleCharOperator(_text[marker], _text[marker + 1],
855 _text[marker + 2], _text[marker + 3])) {
856 marker += 3;
857 type = Lexer::Type::op;
858 token = _text.substr(_cursor, marker - _cursor);
859 _cursor = marker;
860 return true;
861 }
862
863 else if (_eos - marker >= 2 &&
864 isDoubleCharOperator(_text[marker], _text[marker + 1], _text[marker + 2])) {
865 marker += 2;
866 type = Lexer::Type::op;
867 token = _text.substr(_cursor, marker - _cursor);
868 _cursor = marker;
869 return true;
870 }
871
872 else if (isSingleCharOperator(_text[marker])) {
873 token = _text[marker];
874 type = Lexer::Type::op;
875 _cursor = ++marker;
876 return true;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected