lexer: dont consume close tags in single line comments

This commit is contained in:
Ryan Chandler 2022-12-09 02:06:15 +00:00
parent aefa6a89a8
commit 78479f5861
No known key found for this signature in database
GPG Key ID: F113BCADDB3B0CCA
2 changed files with 6 additions and 3 deletions

View File

@ -374,6 +374,11 @@ impl Lexer {
while let Some(c) = state.source.current() { while let Some(c) = state.source.current() {
if *c == b'\n' { if *c == b'\n' {
state.source.next();
break;
}
if state.source.read(2) == [b'?', b'>'] {
break; break;
} }
@ -381,8 +386,6 @@ impl Lexer {
state.source.next(); state.source.next();
} }
state.source.next();
if buffer.starts_with(b"#") { if buffer.starts_with(b"#") {
TokenKind::HashMarkComment(buffer.into()) TokenKind::HashMarkComment(buffer.into())
} else { } else {

View File

@ -23,7 +23,7 @@ fn main() -> ParseResult<()> {
let lexer = Lexer::new(); let lexer = Lexer::new();
let tokens = lexer.tokenize(&contents)?; let tokens = lexer.tokenize(&contents)?;
// dbg!(&tokens); dbg!(&tokens);
let ast = php_parser_rs::parse(tokens)?; let ast = php_parser_rs::parse(tokens)?;