On 12/16/2013 03:09 PM, Gregory Szorc wrote:
> Perhaps Reflect.parse() could grow a new option to expose "comment" nodes or 
> could attach comment metadata to specific node types?

It's really not possible to do the latter.  Comments don't appertain to 
specific nodes at all.  They're just random non-token things interspersed in 
the token stream.  Note that the Esprima stuff mentioned in the other email 
doesn't attempt to put comments in the parse tree -- comment text and locations 
are stored in a side-along array.  The user has to re-associate the comments 
with particular nodes after the fact.  Fundamentally, comments are a 
token-level feature, not a parse tree-level feature.

We sort of can do whatever we want with the parser API.  Except for Esprima 
compatibility for one.  And also except that our parser doesn't track comments 
at all, so we'd have to spend extra time and memory to record locations and 
such, beyond what we do now.  The side-along Esprima approach is probably the 
only way this can work sensibly, given just how many places comments can be 
put; I don't think any API we might have should attempt associations itself.

Jeff
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to