On Monday, 12 February 2018 at 08:47:58 UTC, RazvanN wrote:
Hi Joe,

I suggest you watch this video which explains how the parse time visitors work: https://www.youtube.com/watch?v=tK072jcoWv4 .

On Tuesday, 6 February 2018 at 12:03:06 UTC, joe wrote:

The FuncDeclaration node contains all the information for that.
For example, you can access fd.parent to see if the function is
declared at top-level (in which case, the parent is going to be a module declaration ) or if it is a nested function (in a class, in a struct, in a function). Every AST node contains information about the position in the AST, all you have to do is find how to get that information: which field to access or which
member function to call.


The function average length visitor inherits a transitive visitor which means that the AST traversal logic is already implemented for you. All you have to do is override the visiting methods of interest and do whatever suits you : print stuff, alter the ast, stop the visitation or
continue the visitation (by calling super.visit(ASTnode)).


I know that my explanations might not be very explicit, but if you have an example please post it and we can work on it.


Hello RazvanN,

thank you very much for taking the time to reply and also your effort in making this happen.

I watched the video you linked and read your reply over and over, yet I still have a hard time to wrap my head around this idea.

Like for example DHTML DOM is very easy for me to grasp. It's like riding the car down the country road and I know where I am and which town I'm going to be next, etc.

This AST thing is more like a teleporter room on the Enterprise. Scotty activates the teleporter and a canister appears an a spot labeled imports. He repeats and a canister appears on a spot labeled functions, etc.

I will try again...

Reply via email to