MCPcopy Create free account
hub / github.com/ronreiter/interactive-tutorials / tokenString

Function tokenString

static/js/codemirror/mode/xquery/xquery.js:252–289  ·  view source on GitHub ↗
(quote, f)

Source from the content-addressed store, hash-verified

250 // tokenizer for string literals
251 // optionally pass a tokenizer function to set state.tokenize back to when finished
252 function tokenString(quote, f) {
253 return function(stream, state) {
254 var ch;
255
256 if(isInString(state) && stream.current() == quote) {
257 popStateStack(state);
258 if(f) state.tokenize = f;
259 return ret("string", "string");
260 }
261
262 pushStateStack(state, { type: "string", name: quote, tokenize: tokenString(quote, f) });
263
264 // if we're in a string and in an XML block, allow an embedded code block
265 if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
266 state.tokenize = tokenBase;
267 return ret("string", "string");
268 }
269
270
271 while (ch = stream.next()) {
272 if (ch == quote) {
273 popStateStack(state);
274 if(f) state.tokenize = f;
275 break;
276 }
277 else {
278 // if we're in a string and in an XML block, allow an embedded code block in an attribute
279 if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
280 state.tokenize = tokenBase;
281 return ret("string", "string");
282 }
283
284 }
285 }
286
287 return ret("string", "string");
288 };
289 }
290
291 // tokenizer for variables
292 function tokenVariable(stream, state) {

Callers 2

tokenBaseFunction · 0.70
tokenAttributeFunction · 0.70

Calls 7

isInStringFunction · 0.85
popStateStackFunction · 0.85
pushStateStackFunction · 0.85
isInXmlAttributeBlockFunction · 0.85
retFunction · 0.70
matchMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected