Re: CUP/LEX has limitations
30 Jun 2005 09:59:19 -0400

          From comp.compilers

Related articles
CUP/LEX has limitations (Sharma, Girish \(Girish\)) (2005-06-23)
Re: CUP/LEX has limitations (Scott Nicol) (2005-06-24)
Re: CUP/LEX has limitations (Joel Jones) (2005-06-26)
Re: CUP/LEX has limitations (Scott Nicol) (2005-06-26)
Re: CUP/LEX has limitations (2005-06-30)
Re: CUP/LEX has limitations (glen herrmannsfeldt) (2005-06-30)
Re: CUP/LEX has limitations (Scott Nicol) (2005-07-02)
Re: CUP/LEX has limitations (Martin Ward) (2005-07-03)
Re: CUP/LEX has limitations (A Pietu Pohjalainen) (2005-07-22)
| List of all articles for this month |

Newsgroups: comp.compilers
Date: 30 Jun 2005 09:59:19 -0400
References: 05-06-11505-06-118 05-06-129 05-06-135
Keywords: Java
Posted-Date: 30 Jun 2005 09:59:19 EDT

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 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)
                case 1000:
                default : fun_call2(val);

fun_call2(int val)

Again for handeling this, change emitter's code.


Post a followup to this message

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