예제 #1
0
        private void DetectLexem(string lexem, ParsingResult result)
        {
            switch (PreviousState)
            {
            case State.Identifier:
            {
                if (Language.Keywords.Any(x => String.Compare(x, lexem, true) == 0))
                {
                    if (!result.Keywords.Contains(lexem))
                    {
                        result.Keywords.Add(lexem);
                    }
                }
                else
                {
                    if (!result.Identifiers.Contains(lexem))
                    {
                        result.Identifiers.Add(lexem);
                    }
                }
                break;
            }

            case State.DecimalNumber:
            {
                if (!result.DecimalNumbers.Contains(lexem))
                {
                    result.DecimalNumbers.Add(lexem);
                }
                break;
            }

            case State.Delimiter:
            {
                if (!result.Delimiters.Contains(lexem))
                {
                    result.Delimiters.Add(lexem);
                }
                break;
            }
            }
            LexemEnded = false;
        }