{
try (Reader reader = input.getInput()) {
ThriftLexer lexer = new ThriftLexer(new ANTLRReaderStream(reader));
ThriftParser parser = new ThriftParser(new CommonTokenStream(lexer));
try {
Tree tree = (Tree) parser.document().getTree();
if (parser.getNumberOfSyntaxErrors() > 0) {
throw new IllegalArgumentException("syntax error");
}
return tree;
}