Example #1
0
 public string Visit(DEnumValue dEnumValue)
 {
     return("EVAL");
 }
		public virtual void Visit(DEnumValue n)
		{
			Visit(n as DVariable);
		}
Example #3
0
 public AbstractType Visit(DEnumValue n)
 {
     return(new MemberSymbol(n, resultBase ?? HandleNodeMatch(n.Parent, ctxt), typeBase));
 }
Example #4
0
        public void EnumValue(DEnum mye)
        {
            var ev = new DEnumValue() { Location = la.Location, Description = GetComments(), Parent = mye };

            if (laKind == Identifier && (
                Lexer.CurrentPeekToken.Kind == Assign ||
                Lexer.CurrentPeekToken.Kind == Comma ||
                Lexer.CurrentPeekToken.Kind == CloseCurlyBrace))
            {
                Step();
                ev.Name = t.Value;
                ev.NameLocation = t.Location;
            }
            else
            {
                ev.Type = Type();
                if (Expect(Identifier))
                {
                    ev.Name = t.Value;
                    ev.NameLocation = t.Location;
                }
                else if (IsEOF)
                    ev.NameHash = DTokens.IncompleteIdHash;
            }

            if (laKind == (Assign))
            {
                Step();
                ev.Initializer = AssignExpression(mye);
            }

            ev.EndLocation = t.EndLocation;
            ev.Description += CheckForPostSemicolonComment();

            mye.Add(ev);
        }
Example #5
0
        public void EnumBody(DEnum mye)
        {
            var OldPreviousComment = PreviousComment;
            PreviousComment = new StringBuilder();
            mye.BlockStartLocation = la.Location;

            // While there are commas, loop through
            do
            {
                Step();

                if (laKind == CloseCurlyBrace)
                    break;

                var ev = new DEnumValue() { Location = la.Location, Description = GetComments(), Parent = mye };
                LastParsedObject = ev;

                if (laKind == Identifier && (
                    Lexer.CurrentPeekToken.Kind == Assign ||
                    Lexer.CurrentPeekToken.Kind == Comma ||
                    Lexer.CurrentPeekToken.Kind == CloseCurlyBrace))
                {
                    Step();
                    ev.Name = t.Value;
                    ev.NameLocation = t.Location;
                }
                else
                {
                    ev.Type = Type();
                    if (Expect(Identifier))
                    {
                        ev.Name = t.Value;
                        ev.NameLocation = t.Location;
                    }
                    else if (IsEOF)
                        ExpectingNodeName = true;
                }

                if (laKind == (Assign))
                {
                    Step();
                    ev.Initializer = AssignExpression();
                }

                ev.EndLocation = t.EndLocation;
                ev.Description += CheckForPostSemicolonComment();

                mye.Add(ev);
            }
            while (laKind == Comma);

            Expect(CloseCurlyBrace);
            PreviousComment = OldPreviousComment;

            mye.EndLocation = t.EndLocation;
        }
Example #6
0
 public IconId Visit(DEnumValue n)
 {
     return(GetNodeImage("literal"));
 }
Example #7
0
        private INode[] EnumDeclaration(INode Parent)
        {
            Expect(Enum);
            var ret = new List<INode>();

            var mye = new DEnum() { Location = t.Location, Description = GetComments(), Parent=Parent };
            LastParsedObject = mye;

            ApplyAttributes(mye);

            if (IsBasicType() && laKind != Identifier)
                mye.Type = Type();
            else if (laKind == Auto)
            {
                Step();
                mye.Attributes.Add(new DAttribute(Auto));
            }

            if (laKind == (Identifier))
            {
                // Normal enum identifier
                if (Lexer.CurrentPeekToken.Kind == (Assign) || // enum e = 1234;
                    Lexer.CurrentPeekToken.Kind == (OpenCurlyBrace) || // enum e { A,B,C, }
                    Lexer.CurrentPeekToken.Kind == (Semicolon) || // enum e;
                    Lexer.CurrentPeekToken.Kind == Colon) // enum e : uint {..}
                {
                    Step();
                    mye.Name = t.Value;
                    mye.NameLocation = t.Location;
                }
                else
                {
                    if(mye.Type == null)
                        mye.Type = Type();

                    if (Expect(Identifier))
                    {
                        mye.Name = t.Value;
                        mye.NameLocation = t.Location;
                    }
                }
            }

            if (IsDeclaratorSuffix)
            {
                var _unused = new List<INode>();
                var bt2=DeclaratorSuffixes(out mye.TemplateParameters, out _unused, mye.Attributes);

                if (bt2 != null)
                {
                    bt2.InnerDeclaration = mye.Type;
                    mye.Type = bt2;
                }
            }

            // Enum inhertance type
            if (laKind == (Colon))
            {
                Step();
                mye.Type = Type();
            }

            // Variables with 'enum' as base type
            if (laKind == (Assign) || laKind == (Semicolon))
            {
                do
                {
                    var enumVar = new DVariable();
                    LastParsedObject = enumVar;

                    enumVar.AssignFrom(mye);

                    enumVar.Attributes.Add(new DAttribute(Enum));
                    if (mye.Type != null)
                        enumVar.Type = mye.Type;
                    else
                        enumVar.Type = new DTokenDeclaration(Enum);

                    if (laKind == (Comma))
                    {
                        Step();
                        Expect(Identifier);
                        enumVar.Name = t.Value;
                        enumVar.NameLocation = t.Location;
                    }

                    if (laKind == (Assign))
                    {
                        //Step(); -- expected by initializer
                        enumVar.Initializer = Initializer(); // Seems to be specified wrongly - theoretically there must be an AssignExpression();
                    }
                    enumVar.EndLocation = t.Location;
                    ret.Add(enumVar);
                }
                while (laKind == Comma);

                Expect(Semicolon);
            }
            else
            {
                // Normal enum block
                Expect(OpenCurlyBrace);

                var OldPreviousComment = PreviousComment;
                PreviousComment = "";
                mye.BlockStartLocation = t.Location;

                bool init = true;
                // While there are commas, loop through
                while ((init && laKind != (Comma)) || laKind == (Comma))
                {
                    if (!init) Step();
                    init = false;

                    if (laKind == CloseCurlyBrace) break;

                    var ev = new DEnumValue() { Location = la.Location, Description = GetComments(), Parent = mye };
                    LastParsedObject = ev;

                    if (laKind == Identifier && (
                        Lexer.CurrentPeekToken.Kind == Assign ||
                        Lexer.CurrentPeekToken.Kind == Comma ||
                        Lexer.CurrentPeekToken.Kind == CloseCurlyBrace))
                    {
                        Step();
                        ev.Name = t.Value;
                        ev.NameLocation = t.Location;
                    }
                    else
                    {
                        ev.Type = Type();
                        Expect(Identifier);
                        ev.Name = t.Value;
                        ev.NameLocation = t.Location;
                    }

                    if (laKind == (Assign))
                    {
                        Step();
                        ev.Initializer = AssignExpression();
                    }

                    ev.EndLocation = t.EndLocation;
                    ev.Description += CheckForPostSemicolonComment();

                    mye.Add(ev);
                }
                Expect(CloseCurlyBrace);
                PreviousComment = OldPreviousComment;

                mye.EndLocation = t.EndLocation;

                // Important: Add the enum block, whereas it CAN be unnamed, to the return array
                ret.Add(mye);
            }

            mye.Description += CheckForPostSemicolonComment();

            return ret.ToArray();
        }
Example #8
0
        private INode[] EnumDeclaration()
        {
            Expect(Enum);
            var ret = new List<INode>();

            var mye = new DEnum() { StartLocation = t.Location, Description = GetComments() };
            LastParsedObject = mye;

            ApplyAttributes(mye);

            if (IsBasicType() && laKind != Identifier)
                mye.Type = Type();
            else if (laKind == Auto)
            {
                Step();
                mye.Attributes.Add(new DAttribute(Auto));
            }

            if (laKind == (Identifier))
            {
                // Normal enum identifier
                if (Lexer.CurrentPeekToken.Kind == (Assign) || Lexer.CurrentPeekToken.Kind == (OpenCurlyBrace) || Lexer.CurrentPeekToken.Kind == (Semicolon) || Lexer.CurrentPeekToken.Kind == Colon)
                {
                    Step();
                    mye.Name = t.Value;
                }
                else
                {
                    mye.Type = Type();

                    Expect(Identifier);
                    mye.Name = t.Value;
                }
            }

            // Enum inhertance type
            if (laKind == (Colon))
            {
                Step();
                mye.Type = Type();
            }

            // Variables with 'enum' as base type
            if (laKind == (Assign) || laKind == (Semicolon))
            {
            another_enumvalue:
                var enumVar = new DVariable();
                LastParsedObject = enumVar;

                enumVar.AssignFrom(mye);

                enumVar.Attributes.Add(new DAttribute(Enum));
                if (mye.Type != null)
                    enumVar.Type = mye.Type;
                else
                    enumVar.Type = new DTokenDeclaration(Enum);

                if (laKind == (Comma))
                {
                    Step();
                    Expect(Identifier);
                    enumVar.Name = t.Value;
                }

                if (laKind == (Assign))
                {
                    Step();
                    enumVar.Initializer = AssignExpression();
                }
                enumVar.EndLocation = t.Location;
                ret.Add(enumVar);

                // If there are more than one definitions, loop back
                if (laKind == (Comma))
                    goto another_enumvalue;

                Expect(Semicolon);
            }
            else
            {
                // Normal enum block
                Expect(OpenCurlyBrace);

                var OldPreviousComment = PreviousComment;
                PreviousComment = "";
                mye.BlockStartLocation = t.Location;

                bool init = true;
                // While there are commas, loop through
                while ((init && laKind != (Comma)) || laKind == (Comma))
                {
                    if (!init) Step();
                    init = false;

                    if (laKind == (CloseCurlyBrace)) break;

                    var ev = new DEnumValue() { StartLocation = t.Location, Description = GetComments() };
                    LastParsedObject = ev;

                    if (laKind == (Identifier) && (Lexer.CurrentPeekToken.Kind == (Assign) || Lexer.CurrentPeekToken.Kind == (Comma) || Lexer.CurrentPeekToken.Kind == (CloseCurlyBrace)))
                    {
                        Step();
                        ev.Name = t.Value;
                    }
                    else
                    {
                        ev.Type = Type();
                        Expect(Identifier);
                        ev.Name = t.Value;
                    }

                    if (laKind == (Assign))
                    {
                        Step();
                        ev.Initializer = AssignExpression();
                    }

                    ev.EndLocation = t.EndLocation;
                    ev.Description += CheckForPostSemicolonComment();

                    mye.Add(ev);
                }
                Expect(CloseCurlyBrace);
                PreviousComment = OldPreviousComment;

                mye.EndLocation = t.EndLocation;

                // Important: Add the enum block, whereas it CAN be unnamed, to the return array
                ret.Add(mye);
            }

            mye.Description += CheckForPostSemicolonComment();

            return ret.ToArray();
        }
 public ulong Visit(DEnumValue dEnumValue)
 {
     return(1000003);
 }
Example #10
0
 public CompletionItemKind Visit(DEnumValue n)
 {
     return(CompletionItemKind.EnumMember);
 }
Example #11
0
 public byte Visit(DEnumValue n)
 {
     return((byte)TypeReferenceKind.EnumValue);
 }