From eeb79f3b0435da3edf7eb70f14a465f956e4e0bd Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 8 Jan 2025 08:13:06 -0800 Subject: [PATCH] [naga wgsl-in] Document `front::wgsl::parse::lexer::Lexer`. (#6805) --- naga/src/front/wgsl/parse/lexer.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/naga/src/front/wgsl/parse/lexer.rs b/naga/src/front/wgsl/parse/lexer.rs index df527c1dc4..51b151b53b 100644 --- a/naga/src/front/wgsl/parse/lexer.rs +++ b/naga/src/front/wgsl/parse/lexer.rs @@ -201,10 +201,23 @@ fn is_word_part(c: char) -> bool { #[derive(Clone)] pub(in crate::front::wgsl) struct Lexer<'a> { + /// The remaining unconsumed input. input: &'a str, + + /// The full original source code. + /// + /// We compare `input` against this to compute the lexer's current offset in + /// the source. pub(in crate::front::wgsl) source: &'a str, - // The byte offset of the end of the last non-trivia token. + + /// The byte offset of the end of the most recently returned non-trivia + /// token. + /// + /// This is consulted by the `span_from` function, for finding the + /// end of the span for larger structures like expressions or + /// statements. last_end_offset: usize, + #[allow(dead_code)] pub(in crate::front::wgsl) enable_extensions: EnableExtensions, }