@@ -41,6 +41,21 @@ struct UnclosedCandidate {
4141 depth : usize ,
4242}
4343
44+ /// Implements the [Template list discovery algorithm] but does so lazily and
45+ /// after tokenization.
46+ ///
47+ /// It starts tokenizing `input` in a loop and stops once the first potential
48+ /// template list encontered has been disambiguated; populating the `tokens`
49+ /// buffer in the process.
50+ ///
51+ /// Parameters
52+ ///
53+ /// - `tokens` is expected to be an empty buffer of tokens that this function populates.
54+ /// - `source` is the whole original source code.
55+ /// - `input` is the remaining unconsumed source code.
56+ /// - `ignore_doc_comments` determines if doc comments are treated as [`Token::Trivia`].
57+ ///
58+ /// [Template list discovery algorithm]: https://www.w3.org/TR/WGSL/#template-list-discovery
4459fn consume_tokens < ' a > (
4560 tokens : & mut Vec < ( TokenSpan < ' a > , & ' a str ) > ,
4661 source : & ' a str ,
@@ -124,21 +139,10 @@ fn consume_tokens<'a>(
124139
125140/// Return the token at the start of `input`.
126141///
127- /// If `generic` is `false`, then the bit shift operators `>>` or `<<`
128- /// are valid lookahead tokens for the current parser state (see [§3.1
129- /// Parsing] in the WGSL specification). In other words:
130- ///
131- /// - If `generic` is `true`, then we are expecting an angle bracket
132- /// around a generic type parameter, like the `<` and `>` in
133- /// `vec3<f32>`, so interpret `<` and `>` as `Token::Paren` tokens,
134- /// even if they're part of `<<` or `>>` sequences.
135- ///
136- /// - Otherwise, interpret `<<` and `>>` as shift operators:
137- /// `Token::LogicalOperation` tokens.
142+ /// If `waiting_for_template_end` is `true` and the current token is `>`, then
143+ /// [`Token::TemplateArgsEnd`] is returned instead of `>`, `>>`, `>=` or `>>=`.
138144///
139145/// If `ignore_doc_comments` is true, doc comments are treated as [`Token::Trivia`].
140- ///
141- /// [§3.1 Parsing]: https://gpuweb.github.io/gpuweb/wgsl/#parsing
142146fn consume_token (
143147 input : & str ,
144148 waiting_for_template_end : bool ,
0 commit comments