Skip to content

Commit c0041a3

Browse files
committed
Add tolerance for multiple commas in function arguments - closes nikic#616
1 parent 3cf61fd commit c0041a3

File tree

4 files changed

+1173
-1095
lines changed

4 files changed

+1173
-1095
lines changed

grammar/php7.y

+10-4
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,18 @@ semi:
6868

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

7474
optional_comma:
7575
/* empty */
76-
| ','
76+
| comma
77+
;
78+
79+
comma:
80+
',' { /* nothing */ }
81+
| ',' comma { $this->emitError(new Error('Only one comma was expected', attributes())); }
82+
;
7783

7884
top_statement:
7985
statement { $$ = $1; }
@@ -481,13 +487,13 @@ optional_return_type:
481487
;
482488

483489
argument_list:
484-
'(' ')' { $$ = array(); }
490+
'(' no_comma ')' { $$ = array(); }
485491
| '(' non_empty_argument_list optional_comma ')' { $$ = $2; }
486492
;
487493

488494
non_empty_argument_list:
489495
argument { init($1); }
490-
| non_empty_argument_list ',' argument { push($1, $3); }
496+
| non_empty_argument_list comma argument { push($1, $3); }
491497
;
492498

493499
argument:

0 commit comments

Comments
 (0)