Esempio n. 1
0
        private Status OnKeyword(string text, ref int pos, List <Token> result)
        {
            Status retVal = Status.Begin;

            if (char.IsLetter(text[pos]))
            {
                int m = 1;
                while (pos + m < text.Length && char.IsLetter(text[pos + m]))
                {
                    ++m;
                }
                if (KeywordSet.Contains(text.Substring(pos, m)))
                {
                    result.Add(new Token(text, pos, m, Status.Keyword.ToString()));
                    pos += m;
                }
                else
                {
                    retVal = Status.Idendity;
                }
            }
            else
            {
                retVal = Status.Error;
            }
            return(retVal);
        }
Esempio n. 2
0
 public CSharpIdentifier(string name)
 {
     Name = KeywordSet.Contains(name) ? $"@{name}" : name;
 }