Пример #1
0
        /// <summary>
        /// Parse a module identifier
        /// </summary>
        /// <param name="identifier">Identifier to parse</param>
        public ModuleId ParseModuleId()
        {
            ModuleId moduleId = new ModuleId();

            //parse module identifier
            while (TokenStream.HasNext())
            {
                if (NextToken("identifier", "module identifier.identifier", TokenType.IDENTIFIER))
                {
                    moduleId.AddIdentifier(CurrentToken.GetValue().ToString());
                }
                else
                {
                    //Raise exception
                    throw new UnexpectedToken("Unexpected token found:", CurrentToken.GetValue().ToString(), CurrentToken.GetLine());
                }

                if (TokenStream.HasNext() && TokenStream.Peek(1).GetValue().ToString() == ".")
                {   //Period, so another identifier will appear after this one
                    NextToken(".", "module identifier.identifier", '.');
                }
                else
                {
                    break; //No more module identifier stuff will appear
                }
            }

            return(moduleId);
        }