parser: skip comments in param list

This commit is contained in:
Ryan Chandler 2022-12-05 14:50:19 +00:00
parent 5ae183cead
commit 26a856e8ec
No known key found for this signature in database
GPG Key ID: F113BCADDB3B0CCA
4 changed files with 83 additions and 0 deletions

View File

@ -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
View 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
View File

@ -0,0 +1,3 @@
<?php
function foo(/* $bar */) {}

64
tests/0250/tokens.txt Normal file
View 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,
),
},
]