Skip to content

Commit

Permalink
Add tolerance for multiple commas in function arguments - closes niki…
Browse files Browse the repository at this point in the history
  • Loading branch information
iluuu1994 committed Jun 28, 2019
1 parent 3cf61fd commit c0041a3
Show file tree
Hide file tree
Showing 4 changed files with 1,173 additions and 1,095 deletions.
14 changes: 10 additions & 4 deletions grammar/php7.y
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,18 @@ semi:

no_comma:
/* empty */ { /* nothing */ }
| ',' { $this->emitError(new Error('A trailing comma is not allowed here', attributes())); }
| ',' no_comma { $this->emitError(new Error('A trailing comma is not allowed here', attributes())); }
;

optional_comma:
/* empty */
| ','
| comma
;

comma:
',' { /* nothing */ }
| ',' comma { $this->emitError(new Error('Only one comma was expected', attributes())); }
;

top_statement:
statement { $$ = $1; }
Expand Down Expand Up @@ -481,13 +487,13 @@ optional_return_type:
;

argument_list:
'(' ')' { $$ = array(); }
'(' no_comma ')' { $$ = array(); }
| '(' non_empty_argument_list optional_comma ')' { $$ = $2; }
;

non_empty_argument_list:
argument { init($1); }
| non_empty_argument_list ',' argument { push($1, $3); }
| non_empty_argument_list comma argument { push($1, $3); }
;

argument:
Expand Down

0 comments on commit c0041a3

Please sign in to comment.