public DelphiParser(ParserDebug dgb)
        {
            if (dgb != null)
            {
                this.debug = (ParserDebug)dgb;
            }

            eof_token = DelphiScanner.YYEOF;
            Instance  = this;
        }
        // wrapper for yyparse
        public TranslationUnit Parse(TextReader tr, SourceFile file = null, ParserDebug dgb = null)
        {
            if (dgb != null)
            {
                this.debug = (ParserDebug)dgb;
                DebugLevel = 1;
            }

            if (file != null)
            {
                currentFile = file;
            }
            lexer = new DelphiScanner(tr);
            lexer.yyLexDebugLevel = DebugLevel;

            Object parserRet;

            try
            {
                parserRet = yyparse(lexer);
            }
            catch (MultiDelphiException yye)
            {
                yyerror(yye.Message);
                return(null);
            }
            catch (Exception e)
            {
                ErrorOutput.WriteLine(e.Message + " in line " + lexer.yylineno());
                ErrorOutput.WriteLine(e.StackTrace);
                return(null);
            }
            finally {
                lexer = null;
            }

            if (!(parserRet is TranslationUnit))
            {
                throw new ParserException("Non-final node derived from parsing:" + parserRet.GetType());
            }

            return((TranslationUnit)parserRet);
        }