title: Making a parser to extract function name, parameters, return type
body: <p>I need to parse a C++ class file (.h) and extract the following informations:</p>
  
  <ol>
  <li>Function names</li>
  <li>Return types</li>
  <li>List of parameter types of each function</li>
  </ol>
  
  <p>Assume that there is a special tag using which I can recognize if I need to parse a function or not. </p>
  
  <p>For eg.</p>
  
  <pre><code>#include &lt;someHeader&gt;  
  
  class Test
  {
      public:
      Test();
  
      void fun1();
      // *Expose* //
      void fun2();  
  
  };
  </code></pre>
  
  <p>So I need to parse only fun2().</p>
  
  <p>I read the basic grammar <a href="http://homepages.e3.net.nz/~djm/cppgrammar.html#decl-specifier-seq" rel="nofollow">here</a>, but found it too complex to comprehend. </p>
  
  <p>Q1. I can't make out how complex this task is. Can someone provide a <em>simpler</em> grammar for a function declaration to perform this parsing?</p>
  
  <p>Q2. Is my approach right or should I consider using some library rather than reinventing?</p>
  
  <hr>
  
  <p>Edit: Just to clarify, I don't have problem parsing, problem is more of understanding the grammar I need to parse.</p>