Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Inspiring ES Parser and what do we need LogicalExpressions for

14 views
Skip to first unread message

Staś Małolepszy

unread,
Oct 26, 2012, 1:00:19 AM10/26/12
to tools...@lists.mozilla.org
I came across pretty cool JS parser at:

http://jsparse.meteor.com/

A few thoughts:

- how hard would it be to turn what our parser already produces into
this kind of visualization?

- I can't link to it, so paste the following code on the left:

1 ? true : false

// binary tests
1 && 0 ? true : false
1 & 0 ? true : false
1 > 0 ? true : false
1 + 0 ? true : false

// unary tests
-1 ? true : false
!1 ? true : false

Note how ES defines the conditionals in the AST. 'ternary' is the
equivalent of l20n's ConditionalExpression. But then something
interesting happens: there isn't any special LogicalExpression. It's
just 'binary' or 'unary', and the rest is done via type conversion.

Is there any reason for us to have logical and binary expressions as two
separate symbols defined in the grammar? It seems like there already is
a bit of inconsistency, with unary expressions being both arithmetic
('+', '-') and logical ('!') ones.

Could we simplify this by removing LogicalExpression?

-stas

Axel Hecht

unread,
Oct 26, 2012, 8:18:58 AM10/26/12
to mozilla-t...@lists.mozilla.org
The js harmoy spec uses LogicalOrExpression, and + and - unary operators
are not arithmetic, they're unary. Again, in the js spec.

Axel
0 new messages