Le 07/04/2015 17:24, Marcus Denker a écrit :
On 07 Apr 2015, at 17:20, Yuriy Tymchuk <[email protected]> wrote:
Hi, I need to change source code of a method by for example adding a pragma.
Can I just manipulate it’s AST without carrying about source code anchors?
Because it seems that I have to set from/to values and it looks painful.
I would do the change, print the code and recompile it… not nice, but for now
the easiest.
I conccur with Marcus. It's good enough; RB works this way.
Note that you can change the AST without bothering with the from/to
stuff, in most cases (except syntax errors messages?).
(this way they old AST gets garbage collected and the new one has all the
offsets into the text correct).
It's a lot easier than trying to shift the offsets depending on what you
have added/not added.
I would like to explore if we can’t build a system where everything we
manipulate is ASTs…
You're the compiler guy: everything is an AST :)
Thierry