@@ -309,45 +309,57 @@ window.initSearch = function(rawSearchIndex) {
309
309
}
310
310
311
311
/**
312
+ * This function parses the next query element until it finds `endChar`, calling `getNextElem`
313
+ * to collect each element.
314
+ *
315
+ * If there is no `endChar`, this function will implicitly stop at the end without raising an
316
+ * error.
317
+ *
312
318
* @param {ParsedQuery } query
313
319
* @param {ParserState } parserState
314
320
* @param {Array<QueryElement> } elems - This is where the new {QueryElement} will be added.
315
- * @param {string } limit - This function will stop when it'll encounter this
321
+ * @param {string } endChar - This function will stop when it'll encounter this
316
322
* character.
317
323
*/
318
- function getItemsBefore ( query , parserState , elems , limit ) {
324
+ function getItemsBefore ( query , parserState , elems , endChar ) {
319
325
var turns = 0 ;
320
326
while ( parserState . pos < parserState . length ) {
321
327
var c = parserState . userQuery [ parserState . pos ] ;
322
- if ( c === limit ) {
328
+ if ( c === endChar ) {
323
329
break ;
324
- } else if ( c === "," && limit !== "" && turns > 0 ) {
330
+ } else if ( c === "," && endChar !== "" && turns > 0 ) {
325
331
parserState . pos += 1 ;
326
332
continue ;
327
333
} else if ( c === ":" && isPathStart ( parserState ) ) {
328
334
throw new Error ( "Unexpected `::`: paths cannot start with `::`" ) ;
329
335
} else if ( c === ":" || isEndCharacter ( c ) ) {
330
336
var extra = "" ;
331
- if ( limit === ">" ) {
337
+ if ( endChar === ">" ) {
332
338
extra = "`<`" ;
333
- } else if ( limit === "" ) {
339
+ } else if ( endChar === "" ) {
334
340
extra = "`->`" ;
335
341
}
336
342
throw new Error ( "Unexpected `" + c + "` after " + extra ) ;
337
343
}
338
344
var posBefore = parserState . pos ;
339
- getNextElem ( query , parserState , elems , limit === ">" ) ;
345
+ getNextElem ( query , parserState , elems , endChar === ">" ) ;
340
346
turns += 1 ;
347
+ // This case can be encountered if `getNextElem` encounted a "stop character" right from
348
+ // the start. For example if you have `,,`. In this case, we simply move up the current
349
+ // position to continue the parsing.
341
350
if ( posBefore === parserState . pos ) {
342
351
parserState . pos += 1 ;
343
352
}
344
353
}
345
- // We are either at the end of the string or on the "limit" character, let's move forward
354
+ // We are either at the end of the string or on the `endChar`` character, let's move forward
346
355
// in any case.
347
356
parserState . pos += 1 ;
348
357
}
349
358
350
359
/**
360
+ * Parses the provided `query` input to fill `parserState`. If it encounters an error while
361
+ * parsing `query`, it'll throw an error.
362
+ *
351
363
* @param {ParsedQuery } query
352
364
* @param {ParserState } parserState
353
365
*/
@@ -1194,7 +1206,9 @@ window.initSearch = function(rawSearchIndex) {
1194
1206
}
1195
1207
1196
1208
/**
1197
- * This function is called in case the query has more than one element.
1209
+ * This function is called in case the query has more than one element. In this case, it'll
1210
+ * try to match the items which validates all the elements. For `aa -> bb` will look for
1211
+ * functions which have a parameter `aa` and has `bb` in its returned values.
1198
1212
*
1199
1213
* @param {Row } row
1200
1214
* @param {integer } pos - Position in the `searchIndex`.
0 commit comments