Ejemplo n.º 1
0
        /// <summary>
        /// Returns the token type of the string.
        /// </summary>
        /// <param name="s">A string containing the token to convert</param>
        /// <param name="version">The version of Visual Basic. The version determines if a token is a keyword or not.</param>
        /// <param name="includeUnreserved">Defifes if a non-keyword token will be treated as a keyword.</param>
        /// <returns>A TokenType equivalent to the value contained in s.</returns>
        static public TokenType Parse(string s, LanguageVersion version, bool includeUnreserved)
        {
            if (KeywordTable.ContainsKey(s))
            {
                Keyword Table      = KeywordTable[s];
                bool    isKeyword  = LanguageInfo.Implements(Table.Versions, version);
                bool    isReserved = LanguageInfo.Implements(Table.ReservedVersions, version);

                if (isKeyword && (isReserved || includeUnreserved))
                {
                    return(Table.TokenType);
                }
            }

            return(TokenType.Identifier);
        }