title: How to program Lex and Yacc to parse a partial file
body: <p>Let me tell with an example.
  Suppose the contents of a text file are as follows:</p>
  
  <p>function fun1 { <br>
  &nbsp;&nbsp;  int a, b, c; <br>
  &nbsp;&nbsp;     function fun2 {<br>
  &nbsp;&nbsp;&nbsp;&nbsp;        int d, e;<br>
  &nbsp;&nbsp;&nbsp;&nbsp;        char f g;<br>
  &nbsp;&nbsp;&nbsp;&nbsp;        function fun3 {<br>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;           int h, i;<br>
  &nbsp;&nbsp;&nbsp;&nbsp;        }<br>
  &nbsp;&nbsp;     }<br></p>
  
  <p>In the above text file, the number of opening braces are not matching the number of closing braces. The file as a whole doesn't follow the syntax. However the partial functions fun2 and fun3 follows the syntax. Typically the text file is very large. </p>
  
  <p>If the user wants to parse the entire file ie  function fun1, then the program should output an error as the braces are not matching. However, if the user wants to parse only the partial file ie function fun2/fun3, then the program shouldn't throw out an error as the braces are matching.</p>
  
  <p>I have a question now
  1. Is there a way to let the Lex and Yacc load only a 
     partial file ? If so then how it needs to be done.</p>