1
votes

I have written a simple lexer file from which JFlex has generated a Lexer.java file with no complaints.

However I cannot compile the Lexer.java file without the error:

package java_cup.runtime does not exist

I don't understand what the problem is, as I followed a tutorial which said that as long as the java-cup-11a.jar file is in the root folder then there shouldn't be any classpath problems.

I have spent hours trying to fix this and would appreciate any help.

2

2 Answers

2
votes

I suspect you have just copied a jflex file as the basis for your tutorial experiement and it has a %cup directive near the top. This directive instructs JFlex to generate java code to link the lexer to a CUP generated parser, and you aren't providing the expected CUP jar files to the java compiler.

If you are producing a standalone scanner (which, if you are just starting a tutorial, you probably should be), you need to use the %standalone directive instead.

0
votes
import java_cup.runtime.*;

Just put that at the top of your .jflex file