Re: CUP/LEX has limitations

Scott Nicol <>
24 Jun 2005 09:55:56 -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)
[1 later articles]
| List of all articles for this month |

From: Scott Nicol <>
Newsgroups: comp.compilers
Date: 24 Jun 2005 09:55:56 -0400
Organization: Compilers Central
References: 05-06-115
Keywords: Java, practice
Posted-Date: 24 Jun 2005 09:55:56 EDT

Sharma, Girish (Girish) wrote:
> Presently i am using CUPLEX parsers for my java application. My cup
> file code is increased to 5500 lines and now its crashing and not
> compiling giving "code too large " error because CUP/LEX uses 16-bit
> unicode character set whaich gives limit only 0-65535 and my parser is
> exceeding this limit.

I haven't used CUP/LEX, but I'm quite familiar with the "code too
large" error in Java. Java has a limit of 64k code per method (you,
like I, might be wondering what was being smoked when that decision
was made).

This snags lots of generated code. Tables are no help, because they
are simply shorthand for an array creation plus one assignment for
each table index. And all class-level variables are lumped together
in one method!

For example, write a class like this:

class toobig {
public static void main(String args[]) {
System.out.println("Hello, world!");

static int table[] = {
... [repeat 2000 times]

With Java 1.3 and earlier, it will compile, but if you run the
resulting .class file you will get an exception. With Java 1.4 and
newer, javac will print an error message and exit.

The simplest solution is vintage 16-bit windows. Write a little java
program to read the generated tables and dump them to files using
DataOutputStream. Move these files into one of your jar files. Now
change the source code (or have the above-mentioned java program do it
for you) so that instead of declaring a table with full assignment,
you instead declare the table, load the resource (i.e. the data dump)
as a DataInputStream, then fill in the table in a for() loop reading
from the stream.
Scott Nicol

Post a followup to this message

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