Adding location values to parse trees.

12 views
Skip to first unread message

John J Barton

unread,
Feb 19, 2015, 11:54:30 AM2/19/15
to traceur-comp...@googlegroups.com
Our source maps rely on output trees from transformation having location values from the input tree nodes. As we've moved to use parseStatement and parseExpression extensively, more and more trees have no locations. It turns out that entire source files can disappear. Well ok, I found one somewhat trivial case where the entire file disappears. A file with this source 
  import 'foo.js';
generates no output tree with input locations.

To add more locations when using parseStatement and parseExpression is rather disruptive to the source. These two clever 'functions' make creating parse trees look like parsing source. Adding an argument to set location would make them much less clever.

The most straight forward fix is to have a function like tree.relocate(location); which attaches SourceRange info to a tree. This however would be impure, it would mutate the tree slightly. To add the location without mutation would require -- as far as I can tell -- reconstructing the tree nodes.

Any ideas or opinions?
jjb

Erik Arvidsson

unread,
Feb 19, 2015, 12:39:11 PM2/19/15
to traceur-comp...@googlegroups.com
I'm not sure I follow. Before we had parseStatement etc we used null locations.

One problem I've seen though is that the code sometimes extract the
string of an identifier and then pass that string into parseStatement
instead of passing the token in.
> --
> You received this message because you are subscribed to the Google Groups
> "traceur-compiler-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to traceur-compiler-d...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
erik
Reply all
Reply to author
Forward
0 new messages