No subject

Mon Apr 20 21:23:45 PDT 2009

For example, to create and populate an ast.UnaryOp node, you could use

node =3D ast.UnaryOp(ast.USub(), ast.Num(5, lineno=3D0, col_offset=3D0),
                              lineno=3D0, col_offset=3D0)
The ecmascript AST+ api would wrap the c/c++ parsing/ast api in the
ecmascript engines implementation. Thus the AST in memory
representation will be whatever spidermonkey, v8 etc use. The
serialization/pretty print format may or may not be json. Could be
xml. Or even something more scheme-y e.g
(or x (or y z))
Maybe the api could have a jquery-ish feel.

3) Or even Both
- A api function which takes a json tree and then calls
- the individual api ast builder functions - which are also available

On Sat, May 9, 2009 at 10:50 PM, Brendan Eich <brendan at> wrote:
> On May 9, 2009, at 2:32 PM, David-Sarah Hopwood wrote:
>> I would mildly prefer to use an S-expression-style AST, like this:
>> =A0["||",
>> =A0 ["||",
>> =A0 =A0 ["Id", "X"],
>> =A0 =A0 ["Id", "Y"]],
>> =A0 ["Id", "Z"]]
>> which is more concise, does not lose any useful information, and
>> is easier to remember. This is the same style as used in JsonML
>> (
> Not bad. I will give it a try in the prototype I've started. Thanks for t=
> pointer.
>> It so happens that this is *semantically* equivalent to "a || (b || c)",
>> but that is not an equivalence of abstract syntax.
> I know, that's my point. The connectives can be parsed and evaluated eith=
> way, but the short-circuiting seems to favor right associativity, on one
> hand.
> On the other hand, I'm defying a long tradition here. The precedent going
> back to C (K&R before ANSI got in the loop; ignore Algol and BCPL precede=
> ;-) uses left associativity, and ES1 followed suit.
> So this is not a big deal, and it would be quixotic of me to make too muc=
> of it :-). I wanted to raise it as a potential issue. It's a practical is=
> in SpiderMonkey since we do right-associate || and && in the internal syn=
> tree.
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at

More information about the es-discuss mailing list