From 78479f5861487460cb92d7c9e6c18f69ff29ba32 Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Fri, 9 Dec 2022 02:06:15 +0000 Subject: [PATCH] lexer: dont consume close tags in single line comments --- src/lexer/mod.rs | 7 +++++-- src/main.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lexer/mod.rs b/src/lexer/mod.rs index b46cd54..e268f31 100644 --- a/src/lexer/mod.rs +++ b/src/lexer/mod.rs @@ -374,6 +374,11 @@ impl Lexer { while let Some(c) = state.source.current() { if *c == b'\n' { + state.source.next(); + break; + } + + if state.source.read(2) == [b'?', b'>'] { break; } @@ -381,8 +386,6 @@ impl Lexer { state.source.next(); } - state.source.next(); - if buffer.starts_with(b"#") { TokenKind::HashMarkComment(buffer.into()) } else { diff --git a/src/main.rs b/src/main.rs index b43232d..85c7d55 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ fn main() -> ParseResult<()> { let lexer = Lexer::new(); let tokens = lexer.tokenize(&contents)?; - // dbg!(&tokens); + dbg!(&tokens); let ast = php_parser_rs::parse(tokens)?;