mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 13:04:42 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			695 lines
		
	
	
		
			19 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			695 lines
		
	
	
		
			19 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const PARSED = [
 | |
|     // ML-style HOF
 | |
|     {
 | |
|         query: "(-> F<P>)",
 | |
|         elems: [{
 | |
|             name: "->",
 | |
|             fullPath: ["->"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "->",
 | |
|             generics: [],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "F",
 | |
|                         fullPath: ["f"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "f",
 | |
|                         generics: [
 | |
|                             {
 | |
|                                 name: "P",
 | |
|                                 fullPath: ["p"],
 | |
|                                 pathWithoutLast: [],
 | |
|                                 pathLast: "p",
 | |
|                                 generics: [],
 | |
|                             },
 | |
|                         ],
 | |
|                         typeFilter: -1,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "(-> F<P>)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "(-> P)",
 | |
|         elems: [{
 | |
|             name: "->",
 | |
|             fullPath: ["->"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "->",
 | |
|             generics: [],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "P",
 | |
|                         fullPath: ["p"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "p",
 | |
|                         generics: [],
 | |
|                         typeFilter: -1,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "(-> P)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "(->,a)",
 | |
|         elems: [{
 | |
|             name: "->",
 | |
|             fullPath: ["->"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "->",
 | |
|             generics: [],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "a",
 | |
|                         fullPath: ["a"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "a",
 | |
|                         generics: [],
 | |
|                         typeFilter: -1,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "(->,a)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "(F<P> ->)",
 | |
|         elems: [{
 | |
|             name: "->",
 | |
|             fullPath: ["->"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "->",
 | |
|             generics: [{
 | |
|                 name: "F",
 | |
|                 fullPath: ["f"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "f",
 | |
|                 generics: [
 | |
|                     {
 | |
|                         name: "P",
 | |
|                         fullPath: ["p"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "p",
 | |
|                         generics: [],
 | |
|                     },
 | |
|                 ],
 | |
|                 typeFilter: -1,
 | |
|             }],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "(F<P> ->)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "(P ->)",
 | |
|         elems: [{
 | |
|             name: "->",
 | |
|             fullPath: ["->"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "->",
 | |
|             generics: [{
 | |
|                 name: "P",
 | |
|                 fullPath: ["p"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "p",
 | |
|                 generics: [],
 | |
|                 typeFilter: -1,
 | |
|             }],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "(P ->)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "(,a->)",
 | |
|         elems: [{
 | |
|             name: "->",
 | |
|             fullPath: ["->"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "->",
 | |
|             generics: [{
 | |
|                 name: "a",
 | |
|                 fullPath: ["a"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "a",
 | |
|                 generics: [],
 | |
|                 typeFilter: -1,
 | |
|             }],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "(,a->)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "(aaaaa->a)",
 | |
|         elems: [{
 | |
|             name: "->",
 | |
|             fullPath: ["->"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "->",
 | |
|             generics: [{
 | |
|                 name: "aaaaa",
 | |
|                 fullPath: ["aaaaa"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "aaaaa",
 | |
|                 generics: [],
 | |
|                 typeFilter: -1,
 | |
|             }],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "a",
 | |
|                         fullPath: ["a"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "a",
 | |
|                         generics: [],
 | |
|                         typeFilter: -1,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "(aaaaa->a)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "(aaaaa, b -> a)",
 | |
|         elems: [{
 | |
|             name: "->",
 | |
|             fullPath: ["->"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "->",
 | |
|             generics: [
 | |
|                 {
 | |
|                     name: "aaaaa",
 | |
|                     fullPath: ["aaaaa"],
 | |
|                     pathWithoutLast: [],
 | |
|                     pathLast: "aaaaa",
 | |
|                     generics: [],
 | |
|                     typeFilter: -1,
 | |
|                 },
 | |
|                 {
 | |
|                     name: "b",
 | |
|                     fullPath: ["b"],
 | |
|                     pathWithoutLast: [],
 | |
|                     pathLast: "b",
 | |
|                     generics: [],
 | |
|                     typeFilter: -1,
 | |
|                 },
 | |
|             ],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "a",
 | |
|                         fullPath: ["a"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "a",
 | |
|                         generics: [],
 | |
|                         typeFilter: -1,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "(aaaaa, b -> a)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "primitive:(aaaaa, b -> a)",
 | |
|         elems: [{
 | |
|             name: "->",
 | |
|             fullPath: ["->"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "->",
 | |
|             generics: [
 | |
|                 {
 | |
|                     name: "aaaaa",
 | |
|                     fullPath: ["aaaaa"],
 | |
|                     pathWithoutLast: [],
 | |
|                     pathLast: "aaaaa",
 | |
|                     generics: [],
 | |
|                     typeFilter: -1,
 | |
|                 },
 | |
|                 {
 | |
|                     name: "b",
 | |
|                     fullPath: ["b"],
 | |
|                     pathWithoutLast: [],
 | |
|                     pathLast: "b",
 | |
|                     generics: [],
 | |
|                     typeFilter: -1,
 | |
|                 },
 | |
|             ],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "a",
 | |
|                         fullPath: ["a"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "a",
 | |
|                         generics: [],
 | |
|                         typeFilter: -1,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: 1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "primitive:(aaaaa, b -> a)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "x, trait:(aaaaa, b -> a)",
 | |
|         elems: [
 | |
|             {
 | |
|                 name: "x",
 | |
|                 fullPath: ["x"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "x",
 | |
|                 generics: [],
 | |
|                 typeFilter: -1,
 | |
|             },
 | |
|             {
 | |
|                 name: "->",
 | |
|                 fullPath: ["->"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "->",
 | |
|                 generics: [
 | |
|                     {
 | |
|                         name: "aaaaa",
 | |
|                         fullPath: ["aaaaa"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "aaaaa",
 | |
|                         generics: [],
 | |
|                         typeFilter: -1,
 | |
|                     },
 | |
|                     {
 | |
|                         name: "b",
 | |
|                         fullPath: ["b"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "b",
 | |
|                         generics: [],
 | |
|                         typeFilter: -1,
 | |
|                     },
 | |
|                 ],
 | |
|                 bindings: [
 | |
|                     [
 | |
|                         "output",
 | |
|                         [{
 | |
|                             name: "a",
 | |
|                             fullPath: ["a"],
 | |
|                             pathWithoutLast: [],
 | |
|                             pathLast: "a",
 | |
|                             generics: [],
 | |
|                             typeFilter: -1,
 | |
|                         }],
 | |
|                     ],
 | |
|                 ],
 | |
|                 typeFilter: 10,
 | |
|             }
 | |
|         ],
 | |
|         foundElems: 2,
 | |
|         userQuery: "x, trait:(aaaaa, b -> a)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     // Rust-style HOF
 | |
|     {
 | |
|         query: "Fn () -> F<P>",
 | |
|         elems: [{
 | |
|             name: "Fn",
 | |
|             fullPath: ["fn"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "fn",
 | |
|             generics: [],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "F",
 | |
|                         fullPath: ["f"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "f",
 | |
|                         generics: [
 | |
|                             {
 | |
|                                 name: "P",
 | |
|                                 fullPath: ["p"],
 | |
|                                 pathWithoutLast: [],
 | |
|                                 pathLast: "p",
 | |
|                                 generics: [],
 | |
|                             },
 | |
|                         ],
 | |
|                         typeFilter: -1,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "Fn () -> F<P>",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "FnMut() -> P",
 | |
|         elems: [{
 | |
|             name: "FnMut",
 | |
|             fullPath: ["fnmut"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "fnmut",
 | |
|             generics: [],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "P",
 | |
|                         fullPath: ["p"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "p",
 | |
|                         generics: [],
 | |
|                         typeFilter: -1,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "FnMut() -> P",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "(FnMut() -> P)",
 | |
|         elems: [{
 | |
|             name: "FnMut",
 | |
|             fullPath: ["fnmut"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "fnmut",
 | |
|             generics: [],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "P",
 | |
|                         fullPath: ["p"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "p",
 | |
|                         generics: [],
 | |
|                         typeFilter: -1,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "(FnMut() -> P)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "Fn(F<P>)",
 | |
|         elems: [{
 | |
|             name: "Fn",
 | |
|             fullPath: ["fn"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "fn",
 | |
|             generics: [{
 | |
|                 name: "F",
 | |
|                 fullPath: ["f"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "f",
 | |
|                 generics: [
 | |
|                     {
 | |
|                         name: "P",
 | |
|                         fullPath: ["p"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "p",
 | |
|                         generics: [],
 | |
|                     },
 | |
|                 ],
 | |
|                 typeFilter: -1,
 | |
|             }],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: -1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "Fn(F<P>)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "primitive:fnonce(aaaaa, b) -> a",
 | |
|         elems: [{
 | |
|             name: "fnonce",
 | |
|             fullPath: ["fnonce"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "fnonce",
 | |
|             generics: [
 | |
|                 {
 | |
|                     name: "aaaaa",
 | |
|                     fullPath: ["aaaaa"],
 | |
|                     pathWithoutLast: [],
 | |
|                     pathLast: "aaaaa",
 | |
|                     generics: [],
 | |
|                     typeFilter: -1,
 | |
|                 },
 | |
|                 {
 | |
|                     name: "b",
 | |
|                     fullPath: ["b"],
 | |
|                     pathWithoutLast: [],
 | |
|                     pathLast: "b",
 | |
|                     generics: [],
 | |
|                     typeFilter: -1,
 | |
|                 },
 | |
|             ],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "a",
 | |
|                         fullPath: ["a"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "a",
 | |
|                         generics: [],
 | |
|                         typeFilter: -1,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: 1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "primitive:fnonce(aaaaa, b) -> a",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "primitive:fnonce(aaaaa, keyword:b) -> trait:a",
 | |
|         elems: [{
 | |
|             name: "fnonce",
 | |
|             fullPath: ["fnonce"],
 | |
|             pathWithoutLast: [],
 | |
|             pathLast: "fnonce",
 | |
|             generics: [
 | |
|                 {
 | |
|                     name: "aaaaa",
 | |
|                     fullPath: ["aaaaa"],
 | |
|                     pathWithoutLast: [],
 | |
|                     pathLast: "aaaaa",
 | |
|                     generics: [],
 | |
|                     typeFilter: -1,
 | |
|                 },
 | |
|                 {
 | |
|                     name: "b",
 | |
|                     fullPath: ["b"],
 | |
|                     pathWithoutLast: [],
 | |
|                     pathLast: "b",
 | |
|                     generics: [],
 | |
|                     typeFilter: 0,
 | |
|                 },
 | |
|             ],
 | |
|             bindings: [
 | |
|                 [
 | |
|                     "output",
 | |
|                     [{
 | |
|                         name: "a",
 | |
|                         fullPath: ["a"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "a",
 | |
|                         generics: [],
 | |
|                         typeFilter: 10,
 | |
|                     }],
 | |
|                 ],
 | |
|             ],
 | |
|             typeFilter: 1,
 | |
|         }],
 | |
|         foundElems: 1,
 | |
|         userQuery: "primitive:fnonce(aaaaa, keyword:b) -> trait:a",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: "x, trait:fn(aaaaa, b -> a)",
 | |
|         elems: [
 | |
|             {
 | |
|                 name: "x",
 | |
|                 fullPath: ["x"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "x",
 | |
|                 generics: [],
 | |
|                 typeFilter: -1,
 | |
|             },
 | |
|             {
 | |
|                 name: "fn",
 | |
|                 fullPath: ["fn"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "fn",
 | |
|                 generics: [
 | |
|                     {
 | |
|                         name: "->",
 | |
|                         fullPath: ["->"],
 | |
|                         pathWithoutLast: [],
 | |
|                         pathLast: "->",
 | |
|                         generics: [
 | |
|                             {
 | |
|                                 name: "aaaaa",
 | |
|                                 fullPath: ["aaaaa"],
 | |
|                                 pathWithoutLast: [],
 | |
|                                 pathLast: "aaaaa",
 | |
|                                 generics: [],
 | |
|                                 typeFilter: -1,
 | |
|                             },
 | |
|                             {
 | |
|                                 name: "b",
 | |
|                                 fullPath: ["b"],
 | |
|                                 pathWithoutLast: [],
 | |
|                                 pathLast: "b",
 | |
|                                 generics: [],
 | |
|                                 typeFilter: -1,
 | |
|                             },
 | |
|                         ],
 | |
|                         bindings: [
 | |
|                             [
 | |
|                                 "output",
 | |
|                                 [{
 | |
|                                     name: "a",
 | |
|                                     fullPath: ["a"],
 | |
|                                     pathWithoutLast: [],
 | |
|                                     pathLast: "a",
 | |
|                                     generics: [],
 | |
|                                     typeFilter: -1,
 | |
|                                 }],
 | |
|                             ],
 | |
|                         ],
 | |
|                         typeFilter: -1,
 | |
|                     },
 | |
|                 ],
 | |
|                 bindings: [
 | |
|                     [
 | |
|                         "output",
 | |
|                         [],
 | |
|                     ]
 | |
|                 ],
 | |
|                 typeFilter: 10,
 | |
|             }
 | |
|         ],
 | |
|         foundElems: 2,
 | |
|         userQuery: "x, trait:fn(aaaaa, b -> a)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
|     {
 | |
|         query: 'a,b(c)',
 | |
|         elems: [
 | |
|             {
 | |
|                 name: "a",
 | |
|                 fullPath: ["a"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "a",
 | |
|                 generics: [],
 | |
|                 typeFilter: -1,
 | |
|             },
 | |
|             {
 | |
|                 name: "b",
 | |
|                 fullPath: ["b"],
 | |
|                 pathWithoutLast: [],
 | |
|                 pathLast: "b",
 | |
|                 generics: [{
 | |
|                     name: "c",
 | |
|                     fullPath: ["c"],
 | |
|                     pathWithoutLast: [],
 | |
|                     pathLast: "c",
 | |
|                     generics: [],
 | |
|                     typeFilter: -1,
 | |
|                 }],
 | |
|                 bindings: [
 | |
|                     [
 | |
|                         "output",
 | |
|                         [],
 | |
|                     ]
 | |
|                 ],
 | |
|                 typeFilter: -1,
 | |
|             }
 | |
|         ],
 | |
|         foundElems: 2,
 | |
|         userQuery: "a,b(c)",
 | |
|         returned: [],
 | |
|         error: null,
 | |
|     },
 | |
| ];
 | 
