}
else
{
log("Building lexicon from "+lexiconFile, Project.MSG_INFO);
SAXParserFactory factory = getParserFactory();
factory.setNamespaceAware(true);
XMLReader parser = factory.newSAXParser().getXMLReader();
parser.setEntityResolver(xmlCatalog);
LexiconFactory lexiconfactory = new LexiconFactory();
parser.setContentHandler(lexiconfactory);
try
{
parser.parse(lexiconFile.toString());
}
catch (SAXParseException se)
{
throw new BuildException("Couldn't parse file "+lexiconFile, se);
}
Lexicon lexicon = lexiconfactory.getLexicon();
this.lexicalautomaton = (new LexicalAutomatonBuilder(lexicon, log)).getLexicalAutomaton();
if (cacheFile!=null)
{
ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(cacheFile));
out.writeObject(this.lexicalautomaton);
out.flush();
out.close();
}
}
if (grammarFile!=null)
{
// Grammar
filename = grammarFile.getName();
cacheFile = null;
if (cacheDir!=null)
cacheFile = new File(cacheDir, filename+".obj");
if ((cacheFile!=null) && (cacheFile.exists()) &&
(cacheFile.lastModified()>grammarFile.lastModified()))
{
log("Reading grammar from cache "+cacheFile, Project.MSG_DEBUG);
ObjectInputStream in = new ObjectInputStream(new FileInputStream(cacheFile));
this.parserautomaton = (ParserAutomaton)in.readObject();
in.close();
}
else
{
log("Building grammar from "+grammarFile, Project.MSG_INFO);
SAXParserFactory factory = getParserFactory();
factory.setNamespaceAware(true);
XMLReader parser = factory.newSAXParser().getXMLReader();
parser.setEntityResolver(xmlCatalog);
GrammarFactory grammarfactory = new GrammarFactory();
parser.setContentHandler(grammarfactory);
try