message: smart pointers for iParserContainer
diff: #include <iostream>
  #include <fstream>
  #include <functional>
  +#include <memory>
  #include <antlr4-runtime.h>
  #include <hdlConvertor/universal_fs.h>
  #include <hdlConvertor/verilogPreproc/macroDB.h>
  -
  namespace hdlConvertor {
  template<class antlrLexerT, class antlrParserT, class hdlParserT>
  class iParserContainer {
  public:
  SyntaxErrorLogger syntaxErrLogger;
  - antlrLexerT *lexer;
  - antlr4::CommonTokenStream *tokens;
  - antlrParserT *antlrParser;
  - hdlParserT *hdlParser;
  + std::unique_ptr<antlrLexerT> lexer;
  + std::unique_ptr<antlr4::CommonTokenStream> tokens;
  + std::unique_ptr<antlrParserT> antlrParser;
  + std::unique_ptr<hdlParserT> hdlParser;
  Language lang;
  verilog_pp::MacroDB &defineDB;
  void initParser(antlr4::ANTLRInputStream &input_stream) {
  // create a lexer that feeds off of input CharStream
  - lexer = new antlrLexerT(&input_stream);
  + lexer = std::make_unique<antlrLexerT>(&input_stream);
  // create a buffer of tokens pulled from the lexer
  - tokens = new antlr4::CommonTokenStream(lexer);
  + tokens = std::make_unique<antlr4::CommonTokenStream>(lexer.get());
  // create a parser that feeds off the tokens buffer
  - antlrParser = new antlrParserT(tokens);
  + antlrParser = std::make_unique<antlrParserT>(tokens.get());
  antlrParser->removeErrorListeners();
  lexer->removeErrorListeners();
  @@ -43,13 +43,13 @@ public:
  antlrParser->addErrorListener(&syntaxErrLogger);
  }
  public:
  - hdlObjects::HdlContext *context;
  + hdlObjects::HdlContext &context;
  /*
  * :param context: if context is nullptr new context is generated
  * otherwise specified context is used
  * */
  - iParserContainer(hdlObjects::HdlContext *context, Language _lang,
  + iParserContainer(hdlObjects::HdlContext &context, Language _lang,
  verilog_pp::MacroDB &_defineDB) :
  syntaxErrLogger(), lexer(nullptr), tokens(nullptr), antlrParser(
  nullptr), hdlParser(nullptr), lang(_lang), defineDB(
  @@ -73,8 +73,8 @@ public:
  void _parse(antlr4::ANTLRInputStream &input_stream, bool hierarchyOnly) {
  initParser(input_stream);
  - hdlParser = new hdlParserT(antlrParser->getTokenStream(), context,
  - hierarchyOnly);
  + hdlParser = std::make_unique<hdlParserT>(*antlrParser->getTokenStream(),
  + context, hierarchyOnly);
  // begin parsing at init rule
  try {
  parseFn();
  @@ -82,25 +82,12 @@ public:
  // [todo] check if error really appeared in syntaxErrLogger
  throw;
  }
  - context = hdlParser->getContext();
  -
  - delete hdlParser;
  - hdlParser = nullptr;
  - delete antlrParser;
  - antlrParser = nullptr;
  - delete tokens;
  - tokens = nullptr;
  - delete lexer;
  - lexer = nullptr;
  +
  syntaxErrLogger.error_prefix = "";
  syntaxErrLogger.check_errors(); // Throw exception if errors
  }
  virtual ~iParserContainer() {
  - delete hdlParser;
  - delete antlrParser;
  - delete tokens;
  - delete lexer;
  }
  };
  