@@ -310,10 +310,20 @@ window.initSearch = function(rawSearchIndex) {
310
310
*/
311
311
function getIdentEndPosition ( parserState ) {
312
312
let end = parserState . pos ;
313
+ let foundExclamation = false ;
313
314
while ( parserState . pos < parserState . length ) {
314
315
const c = parserState . userQuery [ parserState . pos ] ;
315
316
if ( ! isIdentCharacter ( c ) ) {
316
- if ( isErrorCharacter ( c ) ) {
317
+ if ( c === "!" ) {
318
+ if ( foundExclamation ) {
319
+ throw new Error ( "Cannot have more than one `!` in an ident" ) ;
320
+ } else if ( parserState . pos + 1 < parserState . length &&
321
+ isIdentCharacter ( parserState . userQuery [ parserState . pos + 1 ] ) )
322
+ {
323
+ throw new Error ( "`!` can only be at the end of an ident" ) ;
324
+ }
325
+ foundExclamation = true ;
326
+ } else if ( isErrorCharacter ( c ) ) {
317
327
throw new Error ( `Unexpected \`${ c } \`` ) ;
318
328
} else if (
319
329
isStopCharacter ( c ) ||
@@ -329,6 +339,7 @@ window.initSearch = function(rawSearchIndex) {
329
339
}
330
340
// Skip current ":".
331
341
parserState . pos += 1 ;
342
+ foundExclamation = false ;
332
343
} else {
333
344
throw new Error ( `Unexpected \`${ c } \`` ) ;
334
345
}
@@ -591,7 +602,7 @@ window.initSearch = function(rawSearchIndex) {
591
602
*
592
603
* The supported syntax by this parser is as follow:
593
604
*
594
- * ident = *(ALPHA / DIGIT / "_")
605
+ * ident = *(ALPHA / DIGIT / "_") [!]
595
606
* path = ident *(DOUBLE-COLON ident)
596
607
* arg = path [generics]
597
608
* arg-without-generic = path
0 commit comments