From e06a27a5b19ea301e84ba2e03fb8e08dc93a1a98 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 27 Jul 2024 18:41:18 -0500 Subject: [PATCH] cl-lexer: Treat `#!/` | `#!\` as a comment --- compiler/cl-lexer/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/cl-lexer/src/lib.rs b/compiler/cl-lexer/src/lib.rs index 399ac4f..1c1d294 100644 --- a/compiler/cl-lexer/src/lib.rs +++ b/compiler/cl-lexer/src/lib.rs @@ -254,10 +254,16 @@ impl<'t> Lexer<'t> { } fn hash(&mut self) -> LResult { match self.peek() { - Ok('!') => self.consume()?.produce_op(Punct::HashBang), + Ok('!') => self.consume()?.hashbang(), _ => self.produce_op(Punct::Hash), } } + fn hashbang(&mut self) -> LResult { + match self.peek() { + Ok('/' | '\'') => self.line_comment(), + _ => self.produce_op(Punct::HashBang), + } + } fn less(&mut self) -> LResult { match self.peek() { Ok('=') => self.consume()?.produce_op(Punct::LtEq),