I am exploring the use of tree grammars...

I exepcted to be able to write something like the following:

tree grammar PipelineWalker;

options {
    language = Java;
    tokenVocab=Pipeline;
    ASTLabelType=CommonTree;
}
@header{
//  import Pipeline;
}
pipeline[Pipeline p]:  ^(PIPE header body) ;

header  : ^('pipeline'  name) {
  System.out.println($pipeline::p.getName());
  $pipeline::p.setName($name.text);}
  ;

Where the intent is to get my 'Pipeline' object from the top level and
modifying it while going down the tree.

The problem is that the references I make to $pipeline::p in my header rule
seem to go untranslated into the generated code:


              System.out.println($pipeline::p.getName());

$pipeline::p.setName((name5!=null?(input.getTokenStream().toString(
              input.getTreeAdaptor().getTokenStartIndex(name5.start),

input.getTreeAdaptor().getTokenStopIndex(name5.start))):null));


Whereas if I write

pipeline[Pipeline p]:  ^(PIPE header[p] body) ;

header[Pipeline p]  : ^('pipeline'  name) {
  System.out.println($p.getName());
  $p.setName($name.text);}
  ;

The translation seems to be better....

So is this a misunderstanding ? Or is this a bug ?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address

Reply via email to