Sure, for those who wrote an ES parser (Hello, Peter ;)) this question
shouldn't be hard. And of course the parser themselves are good helpers in
this case.

Dmitry.

On Mon, Jan 3, 2011 at 5:52 AM, Ariya Hidayat <[email protected]>wrote:

> If you have latest command-line SpiderMonkey or my little tool
> 'SyntaxJS' (see https://github.com/ariya/syntaxjs for the code), you
> can see the syntax tree produced by the parser.
>
> For the case:
>
>  function foo(x) { alert(x); }(1);
>
> the output looks like:
>
>    {
>        "type": "Program",
>        "body": [{
>            "type": "FunctionDeclaration",
>            "id": "foo",
>            "params": [{
>                "type": "Identifier",
>                "name": "x"
>            }],
>            "body": {
>                "type": "BlockStatement",
>                "body": [{
>                    "type": "ExpressionStatement",
>                    "expression": {
>                        "type": "CallExpression",
>                        "callee": {
>                            "type": "Identifier",
>                            "name": "alert"
>                        },
>                        "arguments": [{
>                            "type": "Identifier",
>                            "name": "x"
>                        }]
>                    }
>                }]
>            }
>        },
>        {
>            "type": "ExpressionStatement",
>            "expression": {
>                "type": "Literal",
>                "value": "1"
>            }
>        }]
>    }
>
>
> Just my 2 cents to the otherwise excellent explanation in this thread.
>
>
>
> --
> Ariya Hidayat
> http://www.linkedin.com/in/ariyahidayat
>
> --
> To view archived discussions from the original JSMentors Mailman list:
> http://www.mail-archive.com/[email protected]/
>
> To search via a non-Google archive, visit here:
> http://www.mail-archive.com/[email protected]/
>
> To unsubscribe from this group, send email to
> [email protected]<jsmentors%[email protected]>
>

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to