linking cross-references manually [message #813650] |
Mon, 05 March 2012 09:58  |
Eclipse User |
|
|
|
Hi!
My language has no special syntax for declaring variables, but they are created when they are first used. This use can be in arbitrary places in an expression.
If I understand correctly, this makes it impossible to use the normal reference declarations in the grammar. I would have to do it manually in the linking step, by traversing the expression tree, deciding which is the first use and make all other uses point to it.
Is this correct or at least in the right direction? Did I miss some major detail? Is there some example somewhere about how to manipulate the parse tree while linking?
best regards,
Vlad
|
|
|
Re: linking cross-references manually [message #813772 is a reply to message #813650] |
Mon, 05 March 2012 12:28   |
Eclipse User |
|
|
|
Hi,
This is similar to what I had to do in stackhammer/geppetto @ github -
as the Puppet DSL language it supports is difficult to link.
You can take a look at the linking I am doing - it runs after the
regular linker, it uses adapters to store resolved links, and provides
all the necessary information to the Xtext framework to play nice when
building etc. I also implemented "Open declaration" and "Find
references" based on the "links in adapters".
It works quite well.
(As you will find out, the implementation is somewhat messy, as I
learned how to do things step by step, and it could probably be cleaned
up and made a lot nicer).
If you are interested - the actual linking starts in PPLinker, and the
interesting stuff is in PPResourceLinker.
Happy to answer any questions you may have.
Regards
- henrik
On 2012-05-03 15:58, Vlad Dumitrescu wrote:
> My language has no special syntax for declaring variables, but they are
> created when they are first used. This use can be in arbitrary places in
> an expression.
>
> If I understand correctly, this makes it impossible to use the normal
> reference declarations in the grammar. I would have to do it manually in
> the linking step, by traversing the expression tree, deciding which is
> the first use and make all other uses point to it.
> Is this correct or at least in the right direction? Did I miss some
> major detail? Is there some example somewhere about how to manipulate
> the parse tree while linking?
|
|
|
|
Powered by
FUDForum. Page generated in 0.03307 seconds