By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,109 Members | 969 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,109 IT Pros & Developers. It's quick & easy.

How to program lex and yacc to work on partial file?

P: n/a
I have a very big text file.

Let me tell with an example.
Suppose the contents of a text file are as follows:

Expand|Select|Wrap|Line Numbers
  1. function fun1 {
  2.   int a, b, c;
  3.      function fun2 {
  4.         int d, e;
  5.         char f g;
  6.         function fun3 {
  7.            int h, i;
  8.         }
  9.      }

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.

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.

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.
Nov 26 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.