MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / getParseTokens

Function getParseTokens

tools/shell/linenoise.cpp:1502–1536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1500}
1501
1502std::vector<highlightToken> getParseTokens(char* buf, size_t len) {
1503 std::string cypher(buf, len);
1504 auto inputStream = antlr4::ANTLRInputStream(cypher);
1505
1506 auto cypherLexer = CypherLexer(&inputStream);
1507 auto lexerTokens = antlr4::CommonTokenStream(&cypherLexer);
1508 lexerTokens.fill();
1509
1510 std::vector<highlightToken> tokens;
1511 for (auto& token : lexerTokens.getTokens()) {
1512 highlightToken new_token;
1513 new_token.type = convertToken(token);
1514 if (tokens.empty()) {
1515 new_token.start = 0;
1516 } else {
1517 new_token.start = tokens.back().start + tokens.back().length;
1518 }
1519 new_token.length = token->getText().length();
1520 tokens.push_back(new_token);
1521 }
1522
1523 if (!tokens.empty() && tokens[0].start > 0) {
1524 highlightToken new_token;
1525 new_token.type = tokenType::TOKEN_IDENTIFIER;
1526 new_token.start = 0;
1527 tokens.insert(tokens.begin(), new_token);
1528 }
1529 if (tokens.empty() && cypher.size() > 0) {
1530 highlightToken new_token;
1531 new_token.type = tokenType::TOKEN_IDENTIFIER;
1532 new_token.start = 0;
1533 tokens.push_back(new_token);
1534 }
1535 return tokens;
1536}
1537
1538std::vector<highlightToken> highlightingTokenize(char* buf, size_t len, bool is_shell_command) {
1539 std::vector<highlightToken> tokens;

Callers 1

highlightingTokenizeFunction · 0.85

Calls 7

convertTokenFunction · 0.85
lengthMethod · 0.80
emptyMethod · 0.45
push_backMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected