Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* Allow TERM before commas in function application #86

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

audreyt
Copy link
Contributor

@audreyt audreyt commented Oct 27, 2012

Hi! This patch allows TERM before commas between argument lists, which addresses #63 + #57 and greens the tests for:

console.log 1
, 2

console.log(1
, 2)

I've also factored out secondaryArgumentRest which subsumes implicit object literals, allowing for:

console.log 1,
  2: 3
,
  4: 5
, 6


console.log(1,
  2: 3
,
  4: 5
, 6)

Sanity check / feedback welcome!

  This allows for forms such as:

```coffee
console.log 1,
  2: 3
,
  4: 5
, 6
```
  Supports the following forms (as generated by e.g. js2coffee):

    console.log(1,
      name: name
      , 2)

    console.log(
      name: name
      , 4)

    console.log(name: name
    , 8)

  And also this form with arbitrary indent/dedent around commas:

    console.log(1,
      2,
      4,
    )
    f(
      1
      2
      3
    )

  Because d:DEDENT t1:TERMINATOR? is already part of argumentListContents,
  there's no need to specify them again before the closing paren.
@@ -398,26 +398,33 @@ leftHandSideExpression = callExpression / newExpression
};
}
argumentListContents
= e:argument es:(_ ("," / TERMINATOR) _ argument)* t:("," / TERMINATOR)? {
= e:argument es:(_ (TERM? _ "," _ TERMINATOR? INDENT* / TERMINATOR) _ argument DEDENT*)* t:("," _ DEDENT* TERMINATOR? / TERMINATOR)? {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is too permissive, allowing unbalanced indentation. Please refactor in a way that forces matching indent/dedent markers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants