mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Fix eBNF and handling of whitespace characters when not in a path
This commit is contained in:
parent
4f0a9124bd
commit
e4ee329865
@ -838,7 +838,13 @@ function initSearch(rawSearchIndex) {
|
|||||||
throw ["Unexpected ", c];
|
throw ["Unexpected ", c];
|
||||||
} else if (c === ":" && !isPathStart(parserState)) {
|
} else if (c === ":" && !isPathStart(parserState)) {
|
||||||
if (parserState.typeFilter !== null) {
|
if (parserState.typeFilter !== null) {
|
||||||
throw ["Unexpected ", ":"];
|
throw [
|
||||||
|
"Unexpected ",
|
||||||
|
":",
|
||||||
|
" (expected path after type filter ",
|
||||||
|
parserState.typeFilter + ":",
|
||||||
|
")",
|
||||||
|
];
|
||||||
} else if (query.elems.length === 0) {
|
} else if (query.elems.length === 0) {
|
||||||
throw ["Expected type filter before ", ":"];
|
throw ["Expected type filter before ", ":"];
|
||||||
} else if (query.literalSearch) {
|
} else if (query.literalSearch) {
|
||||||
@ -853,6 +859,9 @@ function initSearch(rawSearchIndex) {
|
|||||||
query.literalSearch = false;
|
query.literalSearch = false;
|
||||||
foundStopChar = true;
|
foundStopChar = true;
|
||||||
continue;
|
continue;
|
||||||
|
} else if (isWhitespace(c)) {
|
||||||
|
skipWhitespace(parserState);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (!foundStopChar) {
|
if (!foundStopChar) {
|
||||||
let extra = "";
|
let extra = "";
|
||||||
@ -983,7 +992,7 @@ function initSearch(rawSearchIndex) {
|
|||||||
* path = ident *(DOUBLE-COLON/{WS} ident) [!]
|
* path = ident *(DOUBLE-COLON/{WS} ident) [!]
|
||||||
* slice = OPEN-SQUARE-BRACKET [ nonempty-arg-list ] CLOSE-SQUARE-BRACKET
|
* slice = OPEN-SQUARE-BRACKET [ nonempty-arg-list ] CLOSE-SQUARE-BRACKET
|
||||||
* arg = [type-filter *WS COLON *WS] (path [generics] / slice)
|
* arg = [type-filter *WS COLON *WS] (path [generics] / slice)
|
||||||
* type-sep = COMMA *(COMMA)
|
* type-sep = *WS COMMA *(COMMA)
|
||||||
* nonempty-arg-list = *(type-sep) arg *(type-sep arg) *(type-sep)
|
* nonempty-arg-list = *(type-sep) arg *(type-sep arg) *(type-sep)
|
||||||
* generics = OPEN-ANGLE-BRACKET [ nonempty-arg-list ] *(type-sep)
|
* generics = OPEN-ANGLE-BRACKET [ nonempty-arg-list ] *(type-sep)
|
||||||
* CLOSE-ANGLE-BRACKET
|
* CLOSE-ANGLE-BRACKET
|
||||||
|
@ -366,7 +366,7 @@ const PARSED = [
|
|||||||
original: "a<> :",
|
original: "a<> :",
|
||||||
returned: [],
|
returned: [],
|
||||||
userQuery: "a<> :",
|
userQuery: "a<> :",
|
||||||
error: 'Expected `,`, `:` or `->` after `>`, found ` `',
|
error: 'Unexpected `<` in type filter (before `:`)',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
query: "mod : :",
|
query: "mod : :",
|
||||||
@ -440,4 +440,108 @@ const PARSED = [
|
|||||||
userQuery: "a<",
|
userQuery: "a<",
|
||||||
error: "Unclosed `<`",
|
error: "Unclosed `<`",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
query: "p<x> , y",
|
||||||
|
elems: [
|
||||||
|
{
|
||||||
|
name: "p",
|
||||||
|
fullPath: ["p"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "p",
|
||||||
|
generics: [
|
||||||
|
{
|
||||||
|
name: "x",
|
||||||
|
fullPath: ["x"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "x",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
typeFilter: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "y",
|
||||||
|
fullPath: ["y"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "y",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
foundElems: 2,
|
||||||
|
original: "p<x> , y",
|
||||||
|
returned: [],
|
||||||
|
userQuery: "p<x> , y",
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: "p<x , y>",
|
||||||
|
elems: [
|
||||||
|
{
|
||||||
|
name: "p",
|
||||||
|
fullPath: ["p"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "p",
|
||||||
|
generics: [
|
||||||
|
{
|
||||||
|
name: "x",
|
||||||
|
fullPath: ["x"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "x",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "y",
|
||||||
|
fullPath: ["y"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "y",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
typeFilter: -1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
foundElems: 1,
|
||||||
|
original: "p<x , y>",
|
||||||
|
returned: [],
|
||||||
|
userQuery: "p<x , y>",
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
query: "p ,x , y",
|
||||||
|
elems: [
|
||||||
|
{
|
||||||
|
name: "p",
|
||||||
|
fullPath: ["p"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "p",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "x",
|
||||||
|
fullPath: ["x"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "x",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "y",
|
||||||
|
fullPath: ["y"],
|
||||||
|
pathWithoutLast: [],
|
||||||
|
pathLast: "y",
|
||||||
|
generics: [],
|
||||||
|
typeFilter: -1,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
foundElems: 3,
|
||||||
|
original: "p ,x , y",
|
||||||
|
returned: [],
|
||||||
|
userQuery: "p ,x , y",
|
||||||
|
error: null,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user