Пример #1
0
        public virtual void Warning(ANTLRMessage msg)
        {
            Template msgST = tool.errMgr.GetMessageTemplate(msg);
            string outputMsg = msgST.Render();
            if (tool.errMgr.FormatWantsSingleLineMessage())
            {
                outputMsg = outputMsg.Replace('\n', ' ');
            }

            Console.Error.WriteLine(outputMsg);
        }
Пример #2
0
        public virtual void Warning(ANTLRMessage msg)
        {
            Template msgST     = tool.errMgr.GetMessageTemplate(msg);
            string   outputMsg = msgST.Render();

            if (tool.errMgr.FormatWantsSingleLineMessage())
            {
                outputMsg = outputMsg.Replace('\n', ' ');
            }

            tool.ConsoleError.WriteLine(outputMsg);
        }
Пример #3
0
        public virtual Template GetMessageTemplate(ANTLRMessage msg)
        {
            Template messageST       = msg.GetMessageTemplate(tool.longMessages);
            Template locationST      = GetLocationFormat();
            Template reportST        = GetReportFormat(msg.GetErrorType().severity);
            Template messageFormatST = GetMessageFormat();

            bool locationValid = false;

            if (msg.line != -1)
            {
                locationST.Add("line", msg.line);
                locationValid = true;
            }
            if (msg.charPosition != -1)
            {
                locationST.Add("column", msg.charPosition);
                locationValid = true;
            }
            if (msg.fileName != null)
            {
                string f = msg.fileName;
                // Don't show path to file in messages; too long.
                string displayFileName = msg.fileName;
                if (File.Exists(f))
                {
                    displayFileName = Path.GetFileName(f);
                }
                locationST.Add("file", displayFileName);
                locationValid = true;
            }

            messageFormatST.Add("id", msg.GetErrorType().code);
            messageFormatST.Add("text", messageST);

            if (locationValid)
            {
                reportST.Add("location", locationST);
            }
            reportST.Add("message", messageFormatST);
            //((DebugST)reportST).inspect();
            //		reportST.impl.dump();
            return(reportST);
        }
Пример #4
0
        public virtual Template GetMessageTemplate(ANTLRMessage msg)
        {
            Template messageST = msg.GetMessageTemplate(tool.longMessages);
            Template locationST = GetLocationFormat();
            Template reportST = GetReportFormat(msg.GetErrorType().severity);
            Template messageFormatST = GetMessageFormat();

            bool locationValid = false;
            if (msg.line != -1)
            {
                locationST.Add("line", msg.line);
                locationValid = true;
            }
            if (msg.charPosition != -1)
            {
                locationST.Add("column", msg.charPosition);
                locationValid = true;
            }
            if (msg.fileName != null)
            {
                string f = msg.fileName;
                // Don't show path to file in messages; too long.
                string displayFileName = msg.fileName;
                if (File.Exists(f))
                {
                    displayFileName = Path.GetFileName(f);
                }
                locationST.Add("file", displayFileName);
                locationValid = true;
            }

            messageFormatST.Add("id", msg.GetErrorType().code);
            messageFormatST.Add("text", messageST);

            if (locationValid)
                reportST.Add("location", locationST);
            reportST.Add("message", messageFormatST);
            //((DebugST)reportST).inspect();
            //		reportST.impl.dump();
            return reportST;
        }
Пример #5
0
        // S U P P O R T  C O D E

        public virtual void Emit(ErrorType etype, ANTLRMessage msg)
        {
            var severity = etype.severity;

            if (severity == ErrorSeverity.WARNING_ONE_OFF || severity == ErrorSeverity.WARNING)
            {
                if (severity == ErrorSeverity.WARNING || !errorTypes.Contains(etype))
                {
                    warnings++;
                    tool.Warning(msg);
                }
            }
            else if (severity == ErrorSeverity.ERROR_ONE_OFF || severity == ErrorSeverity.ERROR)
            {
                if (severity == ErrorSeverity.ERROR || !errorTypes.Contains(etype))
                {
                    errors++;
                    tool.Error(msg);
                }
            }

            errorTypes.Add(etype);
        }
Пример #6
0
        // S U P P O R T  C O D E

        public virtual void Emit(ErrorType etype, ANTLRMessage msg)
        {
            var severity = etype.severity;
            if (severity == ErrorSeverity.WARNING_ONE_OFF || severity == ErrorSeverity.WARNING)
            {
                if (severity == ErrorSeverity.WARNING || !errorTypes.Contains(etype))
                {
                    warnings++;
                    tool.Warning(msg);
                }
            }
            else if (severity == ErrorSeverity.ERROR_ONE_OFF || severity == ErrorSeverity.ERROR)
            {
                if (severity == ErrorSeverity.ERROR || !errorTypes.Contains(etype))
                {
                    errors++;
                    tool.Error(msg);
                }
            }

            errorTypes.Add(etype);
        }
Пример #7
0
        public virtual void Warning(ANTLRMessage msg)
        {
            if (listeners.Count == 0)
            {
                defaultListener.Warning(msg);
            }
            else
            {
                foreach (ANTLRToolListener l in listeners)
                    l.Warning(msg);
            }

            if (warnings_are_errors)
            {
                errMgr.Emit(ErrorType.WARNING_TREATED_AS_ERROR, new ANTLRMessage(ErrorType.WARNING_TREATED_AS_ERROR));
            }
        }
Пример #8
0
        public virtual void Error(ANTLRMessage msg)
        {
            if (listeners.Count == 0)
            {
                defaultListener.Error(msg);
                return;
            }

            foreach (ANTLRToolListener l in listeners)
                l.Error(msg);
        }