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

Function lex_string_literal

src/cypher/cypher.c:102–139  ·  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

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

Callers 1

cbm_lexFunction · 0.85

Calls 1

lex_pushFunction · 0.85

Tested by

no test coverage detected