Skip to content
This repository was archived by the owner on Sep 25, 2018. It is now read-only.

Conversation

@feyzo
Copy link
Collaborator

@feyzo feyzo commented Oct 1, 2014

Closes #285

Merge with: jbeard4/scxml-test-framework#12

Implemented illegal foreach item expressions.
Implemented iterating only on arrays, raising error otherwise

Copy link
Owner

Choose a reason for hiding this comment

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

I think you should check that the top-level node is an ExpressionStatement. Like this:

http://esprima.org/demo/parse.html?code=%2F%2F%20Life%2C%20Universe%2C%20and%20Everything%0A6%20*%207%3B%0A

Expression “6 * 7” yields:

{
    "type": "Program",
    "body": [
        {
            "type": "ExpressionStatement",
            "expression": {
                "type": "BinaryExpression",
                "operator": "*",
                "left": {
                    "type": "Literal",
                    "value": 6,
                    "raw": "6"
                },
                "right": {
                    "type": "Literal",
                    "value": 7,
                    "raw": "7"
                }
            }
        }
    ]
}

Then you do not need to create a constructed expression.

You will still need to wrap esprima.parse it in a try/catch to catch syntax errors.

@feyzo feyzo closed this Nov 30, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants