+ //disconnect from console error output
+ parser.removeErrorListeners();
+
+ final YangErrorListener errorListener = new YangErrorListener();
+ parser.addErrorListener(errorListener);
+
+ if(stream instanceof NamedFileInputStream) {
+ sourceName = stream.toString();
+ } else {
+ sourceName = null;
+ }
+
+// sourceStream = stream;
+// sourceName = parser.getSourceName();
+//
+// if (sourceName == null) {
+// sourceName = stream.toString();
+// }
+ final StatementContext result = parser.statement();
+ errorListener.validate();
+
+ return result;
+ }
+
+ public YangStatementParser.StatementContext getYangAST() {
+ return statementContext;
+ }
+
+ @Override
+ public String toString() {
+ return sourceName;
+ }
+
+// public InputStream getSourceStream() {
+// return sourceStream;
+// }
+
+ private static void logError(Exception e) {
+ if (e instanceof YangSyntaxErrorException) {
+ LOG.error(((YangSyntaxErrorException) e).getFormattedMessage(), e);
+ } else {
+ LOG.error(e.getMessage(), e);
+ }