Re: CUP/LEX has limitations

alpanad@gmail.com
30 Jun 2005 09:59:19 -0400

          From comp.compilers

Related articles
CUP/LEX has limitations girishsharma@lucent.com (Sharma, Girish \(Girish\)) (2005-06-23)
Re: CUP/LEX has limitations snicol@apk.net (Scott Nicol) (2005-06-24)
Re: CUP/LEX has limitations jones@cs.ua.edu (Joel Jones) (2005-06-26)
Re: CUP/LEX has limitations snicol@apk.net (Scott Nicol) (2005-06-26)
Re: CUP/LEX has limitations alpanad@gmail.com (2005-06-30)
Re: CUP/LEX has limitations gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-06-30)
Re: CUP/LEX has limitations snicol@apk.net (Scott Nicol) (2005-07-02)
Re: CUP/LEX has limitations Martin.Ward@durham.ac.uk (Martin Ward) (2005-07-03)
Re: CUP/LEX has limitations pohjalai@cc.helsinki.fi (A Pietu Pohjalainen) (2005-07-22)
| List of all articles for this month |

From: alpanad@gmail.com
Newsgroups: comp.compilers
Date: 30 Jun 2005 09:59:19 -0400
Organization: http://groups.google.com
References: 05-06-11505-06-118 05-06-129 05-06-135
Keywords: Java

As suggested, another solution could be to change the CUP and Lex
source codes, so that it emits a code in which tables are read from a
file rather than being initialized in the program (this is what I have
done because I had to use the parser generator repeatedly not just
once). You need to do two small modifications in CUP/Lex code.


(1) Dump the action and reduce table in a file.
(2) Change emit.java on those places where it emits code which
initialize these tables. Now the emitter should emit the code in which
the tables are read from a file and then are initiaize.


If you have large number of states then you will get code too large
error because the number of case statements will be too high in
generated switch statement. I got this problem when I was generating
the lexical anayzer for COBOL. I broke the switch statement. One way of
breaking the switch statement is suggesetd by the Scott. Another way
could be :


switch(int val)
{
      case 1 :
          .
          .
        default : fun_call1(val);
}


fun_call1(int val)
{
          switch(val)
          {
                case 1000:
                  .
                default : fun_call2(val);
            }
}


fun_call2(int val)
{
          .
          .
}


Again for handeling this, change emitter's code.


Alpana


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.