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

Converting ArrayExpression into a BinaryExpression [docs] #90

Closed
emilos opened this issue Oct 19, 2020 · 1 comment
Closed

Converting ArrayExpression into a BinaryExpression [docs] #90

emilos opened this issue Oct 19, 2020 · 1 comment

Comments

@emilos
Copy link
Contributor

emilos commented Oct 19, 2020

It would be nice to document how to transform:

{
  "type": "ArrayExpression",
  "elements": [
    {
      "type": "Literal",
      "value": "foo"
    },
    {
      "type": "Literal",
      "value": "bar"
    },
    {
      "type": "Literal",
      "value": "baz"
    }
  ]
}

to:

{
  "type": "BinaryExpression",
  "left": {
    "type": "BinaryExpression",
    "left": {
      "type": "Literal",
      "value": "foo"
    },
    "right": {
      "type": "Literal",
      "value": "bar"
    },
    "operator": "+"
  },
  "right": {
    "type": "Literal",
    "value": "baz"
  },
  "operator": "+"
}

Cases to consider:

  • 0 elements
  • 1 element
  • 2 elements
  • 3+ (odd/even)
@emilos
Copy link
Contributor Author

emilos commented Oct 24, 2020

toBinaryExpression was added

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

No branches or pull requests

1 participant