generating call graph using Parserwalker Listener Vs visitor?
<p>After reading <strong>the definition antlr v4 book</strong> , I understood there are two tree-walking mechanisms.</p>

<p>I want to generate SIMPLE call graph for Cpp grammar.</p>

<p><a href="http://uploadkon.ir/fl/d/ODIxMDQ%3D" rel="nofollow noreferrer">this</a> is Cpp14 grammar.</p>

<p>here is part of rules:</p>

<pre><code>postfixexpression
:
    primaryexpression           #PrimaryEX
    | postfixexpression '[' expression ']'      #label9
    | postfixexpression '[' bracedinitlist ']'      #label10
    | postfixexpression '(' expressionlist? ')'     #FuncCall
    | simpletypespecifier '(' expressionlist? ')'   #label11
    | typenamespecifier '(' expressionlist? ')'     #label13
    | simpletypespecifier bracedinitlist        #label14        
    | typenamespecifier bracedinitlist      #label15
    | postfixexpression '.' Template? idexpression  #label16        
    | postfixexpression '-&gt;' Template? idexpression #label17
    | postfixexpression '.' pseudodestructorname        #label18
    | postfixexpression '-&gt;' pseudodestructorname   #label19    
    | postfixexpression '++'            #label20
    | postfixexpression '--'            #label21
    | Dynamic_cast '&lt;' typeid '&gt;' '(' expression ')'    #label22
    | Static_cast '&lt;' typeid '&gt;' '(' expression ')' #label23
    | Reinterpret_cast '&lt;' typeid '&gt;' '(' expression ')'    #label24
    | Const_cast '&lt;' typeid '&gt;' '(' expression ')'  #label25
    | Typeid '(' expression ')'             #label26
    | Typeid '(' typeid ')'         #label27
</code></pre>

<p>my solution is using visitor and creating label for all rules which are necessary to find out the function name. </p>

<p>for example when I enter input file t.mainCpp</p>

<pre><code>static void nastaran(int a, int b)
{
}
int main()
{
    a=func();
}
</code></pre>

<p>the parser tree is :</p>

<p><a href="https://i.stack.imgur.com/FSXtj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FSXtj.png" alt="enter image description here"></a></p>

<p>and I think for getting name of every function which is called in the code ,  need to find this sub-tree :</p>

<p><a href="https://i.stack.imgur.com/jOXtN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jOXtN.png" alt="enter image description here"></a></p>

<p>I mean I override visitor for label FunCall and get identifier value by calling postfixexpression's childeren visitors.
but I don't know if this solution is correct or suitable for this problem or not.should I use visitor ?</p>