Beispiel #1
0
        public void SyntaxError(IRecognizer recognizer, int offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
        {
            // Перегрузка метода SyntaxError -- сохранение полей в отдельную структуру
            EditorMessage em = new EditorMessage()
            {
                Message   = msg,
                Line      = line - 1,
                Character = charPositionInLine,
                Symbol    = "",
                Length    = 1
            };

            if (offendingSymbol != 0) // Для нормального отображения токенов
            {
                em.Symbol = recognizer.Vocabulary.GetDisplayName(offendingSymbol);
            }
            ErrorMessages.Add(em);
        }
Beispiel #2
0
        public override void SyntaxError(IRecognizer recognizer, IToken offendingSymbol, int line, int charPositionInLine, string msg, RecognitionException e)
        {
            // Аналогично лексеру -- перегрузка соответствующего метода
            EditorMessage em = new EditorMessage()
            {
                Message   = msg,
                Line      = line - 1,
                Character = charPositionInLine,
                Symbol    = "",
                Length    = 0
            };

            if (offendingSymbol != null)
            {
                em.Symbol = offendingSymbol.Text;
                em.Length = offendingSymbol.StopIndex - offendingSymbol.StartIndex + 1;
            }

            ErrorMessages.Add(em);
        }