MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / lex_string_literal

Function lex_string_literal

src/cypher/cypher.c:94–131  ·  view source on GitHub ↗

Parse a string literal (with escape handling) into the token list. * *pos points at the character after the opening quote; updated past closing quote. */

Source from the content-addressed store, hash-verified

92/* Parse a string literal (with escape handling) into the token list.
93 * *pos points at the character after the opening quote; updated past closing quote. */
94static void lex_string_literal(const char *input, int len, int *pos, char quote,
95 cbm_lex_result_t *out) {
96 int start = *pos;
97 char buf[CBM_SZ_4K];
98 int blen = 0;
99 const int max_blen = CBM_SZ_4K - 1;
100 while (*pos < len && input[*pos] != quote) {
101 if (input[*pos] == '\\' && *pos + SKIP_ONE < len) {
102 (*pos)++;
103 if (blen < max_blen) {
104 switch (input[*pos]) {
105 case 'n':
106 buf[blen++] = '\n';
107 break;
108 case 't':
109 buf[blen++] = '\t';
110 break;
111 case '\\':
112 buf[blen++] = '\\';
113 break;
114 default:
115 buf[blen++] = input[*pos];
116 break;
117 }
118 }
119 } else {
120 if (blen < max_blen) {
121 buf[blen++] = input[*pos];
122 }
123 }
124 (*pos)++;
125 }
126 buf[blen] = '\0';
127 if (*pos < len) {
128 (*pos)++; /* skip closing quote */
129 }
130 lex_push(out, TOK_STRING, buf, start - SKIP_ONE);
131}
132
133/* Keyword table (case-insensitive lookup) */
134typedef struct {

Callers 1

cbm_lexFunction · 0.85

Calls 1

lex_pushFunction · 0.85

Tested by

no test coverage detected