google/skylark

Information missing in the AST due to string concatenation

Closed this issue · 4 comments

The AST is relatively faithful to the input file and contains a lot of information (locations, raw data). One notable exception is due to an optimization in the parser: "a" + "b" is replaced with "ab".

Is there a way to preserve this information?
Maybe optimizations on the AST could be done in a separate pass (in case we want to do other things like this)?

Currently there is not, but I agree optimizations should be done as an optional separate pass, perhaps by the resolver (or by the bytecode compiler if I ever decide to commit it).

I've committed the compiler (#95) and sent a PR to move the string-concatenation optimization out of the parser (#97).

Fixed now.

Thanks!