Exemplo n.º 1
0
        public virtual object VisitEnumDeclaration(EnumNode enumDeclaration, object data)
        {
            stackMap.Push(enumDeclaration);
            enumDeclaration.Attributes.AcceptVisitor(this, data);

            if (enumDeclaration.BaseClass != null)
            {
                enumDeclaration.BaseClass.AcceptVisitor(this, data);
            }

            if (enumDeclaration.Value != null)
            {
                if (enumDeclaration.Value is NodeCollection <EnumNode> )
                {
                    (enumDeclaration.Value as NodeCollection <EnumNode>).AcceptVisitor(this, data);
                }
                else
                {
                    (enumDeclaration.Value as BaseNode).AcceptVisitor(this, data);
                }
            }

            stackMap.Pop();
            return(null);
        }
Exemplo n.º 2
0
		private void ParseEnum()											
		{
			EnumNode node = new EnumNode(curtok);
			// todo: this needs to have any nested class info, or go in potential container class

			if (curAttributes.Count > 0)
			{
				node.Attributes = curAttributes;
				curAttributes = new NodeCollection<AttributeNode>();
			}

			uint enumMask = ~(uint)Modifier.EnumMods;
			if (((uint)curmods & enumMask) != (uint)Modifier.Empty)
				ReportError("Enum contains illegal modifiers");

			node.Modifiers = curmods;
			curmods = Modifier.Empty;

			Advance(); // advance over Enum token
            node.Name = (IdentifierExpression)ParseIdentifierOrKeyword(false, false, false, true);

			if (curtok.ID == TokenID.Colon) // for base type
			{
				Advance();
				node.BaseClass = ParseType();
			}

            CheckTypeUnicityAndAdd(node);

            this.nameTable.AddIdentifier(new EnumName(node.Name.Identifier,
                ToVisibilityRestriction(node.Modifiers),
                this.currentContext));

            this.currentContext.Enter(node.Name.Identifier, false);

            ClassNode cl = typeStack.Count == 0 ? null : typeStack.Peek();

            if (cl == null)
            {
                namespaceStack.Peek().Enums.Add(node);
            }
            else
            {
                cl.Enums.Add(node);
            }

			AssertAndAdvance(TokenID.LCurly);

            DDW.Collections.NodeCollection<EnumNode> list = new DDW.Collections.NodeCollection<EnumNode>();
            node.Value = list;

			while (curtok.ID != TokenID.RCurly) // guard for empty
			{
				list.Add( ParseEnumMember() );
			}

			AssertAndAdvance(TokenID.RCurly);

			if (curtok.ID == TokenID.Semi)
			{
				Advance();
			}

            this.currentContext.Leave();
		}
Exemplo n.º 3
0
		private EnumNode ParseEnumMember()									
		{
            EnumNode result = new EnumNode(curtok);

			ParsePossibleAttributes(false);

			if (curAttributes.Count > 0)
			{
				result.Attributes = curAttributes;
				curAttributes = new NodeCollection<AttributeNode>();
			}

			if (curtok.ID != TokenID.Ident)
			{
				ReportError("Enum members must be legal identifiers.");
			}

            result.Name = new IdentifierExpression(strings[curtok.Data], curtok);
			Advance();

			if (curtok.ID == TokenID.Equal)
			{
				Advance();
				result.Value = ParseExpression();
			}

			if (curtok.ID == TokenID.Comma)
			{
				Advance();
			}

            this.nameTable.AddIdentifier(new FieldName(result.Name.Identifier,
                NameVisibilityRestriction.Everyone,
                Scope.Static,
                this.currentContext));

			return result;
		}
Exemplo n.º 4
0
        public virtual object VisitEnumDeclaration(EnumNode enumDeclaration, object data)
        {
            stackMap.Push(enumDeclaration);
            enumDeclaration.Attributes.AcceptVisitor(this, data);

            if (enumDeclaration.BaseClass != null )
            {
                enumDeclaration.BaseClass.AcceptVisitor(this, data);
            }

            if (enumDeclaration.Value != null)
            {
                if (enumDeclaration.Value is NodeCollection<EnumNode>)
                {
                    (enumDeclaration.Value as NodeCollection<EnumNode>).AcceptVisitor(this, data);
                }
                else
                {
                    (enumDeclaration.Value as BaseNode).AcceptVisitor(this, data);
                }
            }

            stackMap.Pop();
            return null;

        }