4 ms·
Something like: expr ::= <all the other expressions> | '(' [ expr { ',' expr } ] ')' | '{' { expr } '}' | expr '=>' expr
by UncleEntity 6y ago
Something like:
expr ::= <all the other expressions>
| '(' [ expr { ',' expr } ] ')'
| '{' { expr } '}'
| expr '=>' expr
| identifer '(' expr { ',' expr } ')'
| literal
Tried adding it to the javascript grammar I play with and the parser generator (Coco/R) didn't complain about conflicts -- though it doesn't have tuples so YMMV.
--edit--
Played with it a bit more and added tuples (as a replacement for '(' expr ')' grouping expression (exactly like the now-edited example above) and it still seems happy. If I were to add this to the grammar for real I'd have to monkey around with it some more to ensure there was an actual '(' ... ')' expression before the => but seems easily doable by transforming the grammar a bit.