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

Method isDOM

src/Lexer.cpp:926–1042  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Lexer::Type::dom [ | + . ] [ . ] Configuration: rc. System: tw.syncneeded tw.program tw.args tw.width tw.height context.program // 2017-02-25 Deprecated in 2.6.0 context.args // 2017-02-25 Deprecated in 2.6.0 context.width // 2017-02-25 Deprecated

Source from the content-addressed store, hash-verified

924// annotations.<N>.description
925//
926bool Lexer::isDOM(std::string& token, Lexer::Type& type) {
927 std::size_t marker = _cursor;
928
929 // rc. ...
930 std::string partialToken;
931 Lexer::Type partialType;
932 if (isLiteral("rc.", false, false) && isWord(partialToken, partialType)) {
933 token = _text.substr(marker, _cursor - marker);
934 type = Lexer::Type::dom;
935 return true;
936 } else
937 _cursor = marker;
938
939 // Literals
940 if (isOneOf({"tw.syncneeded", "tw.program", "tw.args", "tw.width", "tw.height", "tw.version",
941 "context.program", "context.args", "context.width", "context.height",
942 "system.version", "system.os"},
943 false, true)) {
944 token = _text.substr(marker, _cursor - marker);
945 type = Lexer::Type::dom;
946 return true;
947 }
948
949 // Optional:
950 // <uuid>.
951 // <id>.
952 std::string extractedToken;
953 Lexer::Type extractedType;
954 if (isUUID(extractedToken, extractedType, false) || isInteger(extractedToken, extractedType)) {
955 if (!isLiteral(".", false, false)) {
956 _cursor = marker;
957 return false;
958 }
959 }
960
961 // Any failure after this line should rollback to the checkpoint.
962 std::size_t checkpoint = _cursor;
963
964 // [prefix]tags.<word>
965 if (isLiteral("tags", false, false) && isLiteral(".", false, false) &&
966 isWord(partialToken, partialType)) {
967 token = _text.substr(marker, _cursor - marker);
968 type = Lexer::Type::dom;
969 return true;
970 } else
971 _cursor = checkpoint;
972
973 // [prefix]attribute (bounded)
974 if (isOneOf(attributes, false, true)) {
975 token = _text.substr(marker, _cursor - marker);
976 type = Lexer::Type::dom;
977 return true;
978 }
979
980 // [prefix]attribute. (unbounded)
981 if (isOneOf(attributes, false, false)) {
982 if (isLiteral(".", false, false)) {
983 std::string attribute = _text.substr(checkpoint, _cursor - checkpoint - 1);

Callers

nothing calls this directly

Calls 1

tokenMethod · 0.80

Tested by

no test coverage detected