[antlr-interest] newbie stringtemplate NoClassDefFoundError problem
Pete Siemsen
siemsen at UCAR.EDU
Fri Oct 26 19:27:22 PDT 2007
My translator recognizes input, so now I'm trying to emit output.
I'm using string templates for the first time. The test rig looks
like this:
import org.antlr.runtime.*;
import org.antlr.stringtemplate.*;
import java.io.*;
public class cimmof2java {
public static void main(String[] args) throws Exception {
String inputFileName = args[0];
String stgFileName = args[1];
String outputDirectoryName = args[2];
StringTemplateGroup templates = null;
// Load contents of template group file into
"templates"
try {
FileReader groupFileR = new FileReader
(stgFileName);
templates = new StringTemplateGroup
(groupFileR);
groupFileR.close();
} catch (IOException FileNotFoundException) {
System.out.println("couldn't open string
template group file: " + stgFileName);
System.exit(1);
}
// Open an input file stream from the given file name
CharStream input = new ANTLRFileStream(inputFileName);
// Create a lexer that feeds from the input file stream
cimmof2javaLexer lexer = new cimmof2javaLexer(input);
// Create a stream of tokens fed by the lexer
CommonTokenStream tokens = new CommonTokenStream
(lexer);
// Create a parser that feeds off the token stream
cimmof2javaParser parser = new cimmof2javaParser
(tokens);
// Give the parser the string templates
parser.setTemplateLib(templates);
// Begin parsing at rule mofSpecification
cimmof2javaParser.mofSpecification_return retVal =
parser.mofSpecification(outputDirectoryName);
StringTemplate output = (StringTemplate)
retVal.getTemplate();
// Emit the translation
System.out.println(output.toString());
}
}
When I give it the name of an existing .stg file, it gives
Exception in thread "main" java.lang.NoClassDefFoundError: antlr/
TokenStream
at cimmof2java.main(cimmof2java.java:16)
If I give it a .stg file name name of a file that doesn't exist, it
gives
couldn't open string template group file: bogus.stg
So something happens in the creation of "templates". I'm not real
strong with Java class location problems. What's the problem finding
antlr/TokenStream? Any help appreciated.
-- Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20071026/e4f32bbd/attachment.html
More information about the antlr-interest
mailing list