I have been trying to parse this and translate it using a .stg file, and it
does not work.  Every time, it parses  I have no idea what's going on.
Help!?

Hop.stg:

group Hop;
start(p) ::= "<pack>"
package(name) ::= "packagedafdjk <name>"
qualified_name(name) ::= "<name>"


HopSymbolTableWalker.g:

tree grammar HopSymbolTableWalker;

options {
tokenVocab=Hop;
 ASTLabelType=CommonTree;
output = template;
}
...
start
@after{$st = %start(p={$pack.text});}
: (pack = package_rule ref = reference+          // -> start(pack={$pack.st
})
 | ref = reference+ pack = package_rule
| pack = package_rule                                  // -> start(pack={$
pack.st})
 | ref = reference+
| )
 cl = class_declaration  EOF //Declaring a class name
;

package_rule
@after{$st = %package(name={$qn.text});}
: PACKAGE_NAME qn=qualified_name
 {
thisPackage = $qn.type;
}
 ;

qualified_name returns [QualifiedNameDescriptor type]
@after {$st = %{result};}
@init {
 String result = "";
}
: ^(QUALIFIED_NAME ids+= ID (PERIOD ids+=ID)*)
 {
QualifiedNameDescriptor t = new QualifiedNameDescriptor();
t.setLineBegin(((CommonTree)$ids.get(0)).token.getLine());
 t.setColumnBegin(((CommonTree)$ids.get(0)).token.getCharPositionInLine());
/*t.setNameFromList($ids);
 */
String name = "";
Iterator it = $ids.iterator();

         while(it.hasNext()) {
             name += ((CommonTree) it.next()).getText();

             if(it.hasNext()) {
                 name += $PERIOD.text;
           }

             }
             t.setName(name);

result = name;

t.setLineEnd(((CommonTree)$ids.get($ids.size() - 1)).token.getLine());
 t.setColumnEnd(((CommonTree)$ids.get($ids.size() -
1)).token.getCharPositionInLine());
$type = t;
 }                                                                //->
qualified_name(name={result})
;



Thanks for your ideas.  I'm absolutely stuck.

Kim

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

-- 
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.

Reply via email to