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