Ejemplo n.º 1
0
        public override bool IsImplicitMatch(CSLexerHighlighter lexer)
        {
            if (!char.IsWhiteSpace(lexer.Previous) &&
                !lexer.IsSpecialSymbol(lexer.Previous, DelimiterType.End))
            {
                return(false);
            }

            bool matchedNumber = false;

            while (!lexer.EndOfStream)
            {
                if (IsNumberOrDecimalPoint(lexer.ReadNext()))
                {
                    matchedNumber = true;
                    lexer.Commit();
                }
                else
                {
                    lexer.Rollback();
                    break;
                }
            }

            return(matchedNumber);
        }
Ejemplo n.º 2
0
        public override bool IsImplicitMatch(CSLexerHighlighter lexer)
        {
            if (!char.IsWhiteSpace(lexer.Previous) &&
                !lexer.IsSpecialSymbol(lexer.Previous, DelimiterType.End))
            {
                return(false);
            }

            shortlist.Clear();

            int  currentIndex = 0;
            char currentChar  = lexer.ReadNext();

            for (int i = 0; i < Keywords.Length; i++)
            {
                if (Keywords[i][0] == currentChar)
                {
                    shortlist.Add(Keywords[i]);
                }
            }

            if (shortlist.Count == 0)
            {
                return(false);
            }

            do
            {
                if (lexer.EndOfStream)
                {
                    RemoveLongStrings(currentIndex + 1);
                    break;
                }

                currentChar = lexer.ReadNext();
                currentIndex++;

                if (char.IsWhiteSpace(currentChar) ||
                    lexer.IsSpecialSymbol(currentChar, DelimiterType.Start))
                {
                    RemoveLongStrings(currentIndex);
                    lexer.Rollback(1);
                    break;
                }

                foreach (string keyword in shortlist)
                {
                    if (currentIndex >= keyword.Length || keyword[currentIndex] != currentChar)
                    {
                        removeList.Push(keyword);
                    }
                }

                while (removeList.Count > 0)
                {
                    shortlist.Remove(removeList.Pop());
                }
            }while (shortlist.Count > 0);

            return(shortlist.Count > 0);
        }
Ejemplo n.º 3
0
        public override bool IsImplicitMatch(CSLexerHighlighter lexer)
        {
            if (lexer == null)
            {
                return(false);
            }

            if (!char.IsWhiteSpace(lexer.Previous) &&
                !char.IsLetter(lexer.Previous) &&
                !char.IsDigit(lexer.Previous) &&
                !lexer.IsSpecialSymbol(lexer.Previous, DelimiterType.End))
            {
                return(false);
            }

            shortlist.Clear();

            int  currentIndex = 0;
            char currentChar  = lexer.ReadNext();

            for (int i = symbols.Length - 1; i >= 0; i--)
            {
                if (symbols[i][0] == currentChar)
                {
                    shortlist.Add(symbols[i]);
                }
            }

            if (shortlist.Count == 0)
            {
                return(false);
            }

            do
            {
                if (lexer.EndOfStream)
                {
                    RemoveLongStrings(currentIndex + 1);
                    break;
                }

                currentChar = lexer.ReadNext();
                currentIndex++;

                if (char.IsWhiteSpace(currentChar) ||
                    char.IsLetter(currentChar) ||
                    char.IsDigit(currentChar) ||
                    lexer.IsSpecialSymbol(currentChar, DelimiterType.Start))
                {
                    RemoveLongStrings(currentIndex);
                    lexer.Rollback(1);
                    break;
                }

                foreach (string symbol in shortlist)
                {
                    if (currentIndex >= symbol.Length || symbol[currentIndex] != currentChar)
                    {
                        removeList.Push(symbol);
                    }
                }

                while (removeList.Count > 0)
                {
                    shortlist.Remove(removeList.Pop());
                }
            }while (shortlist.Count > 0);

            return(shortlist.Count > 0);
        }