[antlr-interest] import XXX; -> eror '.' expected

Kenny Tilton ktilton at nyc.rr.com
Thu Dec 29 16:26:46 PST 2005


Still a newby, to Antlr and Java....

I ran antlr on the StdCParser.g in the cgram download.

The resulting StdCLexer.java begins:

// $ANTLR 2.7.5 (20050201): "StdCParser.g" -> "StdCLexer.java"$

import java.io.InputStream;
...etc...
import antlr.SemanticException;

        import CToken;
        import java.io.*;
        import LineObject;
        import antlr.*;

javac (under SDK 1.4.2_10) whines about '.' expected just before the 
semi-colon on both CToken abd LineObject. I double-checked my classpath 
setting to make sure the home directory was in the path.

A little Googling turned up an article saying import actually requires a 
package name, since there is no need to import something in the same 
package. The writer indicated that prior to 1.4 one could get away with 
the above practice, but in 1.4 they started enforcing the rule.

Am I on the right track, or am I missing something more important? In 
the meantime I will change the StdCParser.g to not have those two 
imports and soldier on.

kenny



More information about the antlr-interest mailing list