mirror of
https://github.com/danog/parser.git
synced 2024-11-30 04:29:13 +01:00
parser: skip comments in param list
This commit is contained in:
parent
5ae183cead
commit
26a856e8ec
@ -56,6 +56,8 @@ impl Parser {
|
||||
|
||||
self.lparen(state)?;
|
||||
|
||||
state.skip_comments();
|
||||
|
||||
while !state.is_eof() && state.current.kind != TokenKind::RightParen {
|
||||
self.gather_attributes(state)?;
|
||||
|
||||
@ -143,6 +145,8 @@ impl Parser {
|
||||
by_ref,
|
||||
});
|
||||
|
||||
state.skip_comments();
|
||||
|
||||
if state.current.kind == TokenKind::Comma {
|
||||
state.next();
|
||||
} else {
|
||||
|
12
tests/0250/ast.txt
Normal file
12
tests/0250/ast.txt
Normal file
@ -0,0 +1,12 @@
|
||||
[
|
||||
Function {
|
||||
name: Identifier {
|
||||
name: "foo",
|
||||
},
|
||||
attributes: [],
|
||||
params: [],
|
||||
body: [],
|
||||
return_type: None,
|
||||
by_ref: false,
|
||||
},
|
||||
]
|
3
tests/0250/code.php
Normal file
3
tests/0250/code.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
function foo(/* $bar */) {}
|
64
tests/0250/tokens.txt
Normal file
64
tests/0250/tokens.txt
Normal file
@ -0,0 +1,64 @@
|
||||
[
|
||||
Token {
|
||||
kind: OpenTag(
|
||||
Full,
|
||||
),
|
||||
span: (
|
||||
1,
|
||||
1,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: Function,
|
||||
span: (
|
||||
3,
|
||||
1,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: Identifier(
|
||||
"foo",
|
||||
),
|
||||
span: (
|
||||
3,
|
||||
10,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: LeftParen,
|
||||
span: (
|
||||
3,
|
||||
13,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: Comment(
|
||||
"/* $bar */",
|
||||
),
|
||||
span: (
|
||||
3,
|
||||
14,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: RightParen,
|
||||
span: (
|
||||
3,
|
||||
24,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: LeftBrace,
|
||||
span: (
|
||||
3,
|
||||
26,
|
||||
),
|
||||
},
|
||||
Token {
|
||||
kind: RightBrace,
|
||||
span: (
|
||||
3,
|
||||
27,
|
||||
),
|
||||
},
|
||||
]
|
Loading…
Reference in New Issue
Block a user