use of net.sourceforge.processdash.data.compiler.lexer.LexerException in project processdash by dtuma.
the class DataRepository method loadDatafile.
private String loadDatafile(String filename, Reader datafile, Map dest, boolean followIncludes, boolean close) throws FileNotFoundException, IOException, InvalidDatafileFormat {
//debug("loadDatafile("+filename+")");
// Initialize data, file, and read buffer.
BufferedReader in = new BufferedReader(datafile);
FileLoader loader = new FileLoader(dest, followIncludes);
String defineDecls = null;
if (filename != null)
defineDecls = (String) defineDeclarations.get(filename);
defineDecls = prependGlobalDefineDeclarations(defineDecls);
try {
CppFilterReader readIn = new CppFilterReader(in, defineDecls);
Parser p = new Parser(new Lexer(new PushbackReader(readIn, 1024)));
// Parse the file.
Start tree = p.parse();
// Apply the file loader.
tree.apply(loader);
} catch (ParserException pe) {
String message = "Could not parse " + filename + "; " + pe.getMessage();
TemplateLoader.logTemplateError(message);
throw new InvalidDatafileFormat(message);
} catch (LexerException le) {
String message = "Could not parse " + filename + "; " + le.getMessage();
TemplateLoader.logTemplateError(message);
throw new InvalidDatafileFormat(message);
} catch (LoadingException load) {
Exception root = load.getRoot();
if (root instanceof FileNotFoundException)
throw (FileNotFoundException) root;
if (root instanceof IOException)
throw (IOException) root;
if (root instanceof InvalidDatafileFormat)
throw (InvalidDatafileFormat) root;
System.err.println("Unusual exception when loading file: " + root);
root.printStackTrace();
throw new IOException(root.getMessage());
} finally {
if (close)
in.close();
}
return loader.getInheritedDatafile();
}
Aggregations