Hi,

I have now the C Sharp Parser and C Sharp Lexer. Now I need to implement the 
ASTVisitor to manipulate AST for C# after parsing in a directory/file.
I am doing sth like this "CSParser.compilation_unit_return x = 
parser.compilation_unit();" in my main class.

1. The problem now is how do I get the tree / root of the tree out of the 
compilation unit return to me?

2. From the TreeVisitor 
(http://www.antlr.org/api/CSharp/class_antlr_1_1_runtime_1_1_tree_1_1_tree_visitor.html),
 there is a Visit() method which has the traversal logic.
I plan to use it to implement the Action method in the Visitor pattern. 
Then for each visit to the each node (class, method, variables etc), I will 
write another class which has all the different visits (eg. Visit(class, 
action) n Visit(method, action)). 
The problem is how do I gain access to the info of class, methods, variables 
etc of the tree? Through the Adaptor? How do I get the adaptor from the 
compilation unit?
If not through the Adaptor, what other means can I use?

4. In addition, the Visit() method takes in 2 parameters one of which is an 
object, the other is a ITreeVisitorAction.
So now what is the object? The tree or the root of the tree?
For the ITreeVisitorAction and ITreeAdaptor, how do I know the right instance 
of which concrete class (BaseTree or CommonTree or other tree) to use, can I 
get clues it from the compilation unit as well?


Would be grateful if anyone can help me with at least one of the doubts...

Li Yen



--~--~---------~--~----~------------~-------~--~----~
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/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

Reply via email to