use of net.jangaroo.utils.BOMStripperInputStream in project jangaroo-tools by CoreMedia.
the class JangarooParser method doParse.
public static CompilationUnit doParse(InputSource in, CompileLog log, SemicolonInsertionMode semicolonInsertionMode) {
Scanner s;
try {
s = new Scanner(new InputStreamReader(new BOMStripperInputStream(in.getInputStream()), "UTF-8"));
} catch (IOException e) {
throw new CompilerError("Cannot read input file: " + in.getPath(), e);
}
s.setInputSource(in);
JooParser p = new JooParser(s);
p.setCompileLog(log);
p.setSemicolonInsertionMode(semicolonInsertionMode);
try {
Symbol tree = p.parse();
return (CompilationUnit) tree.value;
} catch (Scanner.ScanError se) {
log.error(se.getSym(), se.getMessage());
return null;
} catch (JooParser.FatalSyntaxError e) {
// message already logged in parser
return null;
} catch (Exception e) {
throw new IllegalArgumentException("could not parse Jangaroo source", e);
}
}
Aggregations