mirror of
https://github.com/danog/parser.git
synced 2025-01-22 04:51:13 +01:00
lexer: fix comment tokenization skipping next character
This commit is contained in:
parent
aa9f33a726
commit
4b73900b59
@ -349,7 +349,6 @@ impl Lexer {
|
||||
[] => unreachable!(),
|
||||
}
|
||||
}
|
||||
state.next();
|
||||
|
||||
if buffer.starts_with(b"/**") {
|
||||
TokenKind::DocComment(buffer.into())
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::process::exit;
|
||||
|
||||
use php_parser_rs::prelude::Lexer;
|
||||
use php_parser_rs::prelude::Parser;
|
||||
|
||||
|
@ -155,6 +155,7 @@ impl Parser {
|
||||
|
||||
pub(in crate::parser) fn args_list(&self, state: &mut State) -> ParseResult<Vec<Arg>> {
|
||||
self.lparen(state)?;
|
||||
state.skip_comments();
|
||||
|
||||
let mut args = Vec::new();
|
||||
|
||||
|
18
tests/0245/ast.txt
Normal file
18
tests/0245/ast.txt
Normal file
@ -0,0 +1,18 @@
|
||||
[
|
||||
Expression {
|
||||
expr: Array {
|
||||
items: [
|
||||
ArrayItem {
|
||||
key: None,
|
||||
value: Call {
|
||||
target: Identifier {
|
||||
name: "foo",
|
||||
},
|
||||
args: [],
|
||||
},
|
||||
unpack: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
3
tests/0245/code.php
Normal file
3
tests/0245/code.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
[foo(/* comment here */)];
|
64
tests/0245/tokens.txt
Normal file
64
tests/0245/tokens.txt
Normal file
@ -0,0 +1,64 @@
|
||||
[
|
||||
Token {
|
||||
kind: OpenTag(
|
||||
Full,
|
||||
),
|
||||
span: (
|
||||
1,
|
||||
1,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: LeftBracket,
|
||||
span: (
|
||||
3,
|
||||
1,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: Identifier(
|
||||
"foo",
|
||||
),
|
||||
span: (
|
||||
3,
|
||||
2,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: LeftParen,
|
||||
span: (
|
||||
3,
|
||||
5,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: Comment(
|
||||
"/* comment here */",
|
||||
),
|
||||
span: (
|
||||
3,
|
||||
6,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: RightParen,
|
||||
span: (
|
||||
3,
|
||||
24,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: RightBracket,
|
||||
span: (
|
||||
3,
|
||||
25,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: SemiColon,
|
||||
span: (
|
||||
3,
|
||||
26,
|
||||
),
|
||||
},
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user