Esempio n. 1
0
        List <DAttribute> GetCurrentAttributeSet()
        {
            var attrs = new List <DAttribute>();

            foreach (var attr in BlockAttributes.ToArray())
            {
                attrs.Add(attr);
            }

            while (DeclarationAttributes.Count > 0)
            {
                var attr = DeclarationAttributes.Pop();

                var m = attr as Modifier;
                if (m != null)
                {
                    // If accessor already in attribute array, remove it
                    if (DTokens.IsVisibilityModifier(m.Token))
                    {
                        Modifier.CleanupAccessorAttributes(attrs);
                    }

                    if (!Modifier.ContainsAttribute(attrs, m.Token))
                    {
                        attrs.Add(attr);
                    }
                }
                else
                {
                    attrs.Add(attr);
                }
            }

            return(attrs);
        }
Esempio n. 2
0
 public override string ToString()
 {
     if (Kind == DTokens.Identifier || Kind == DTokens.Literal)
     {
         return(LiteralValue is string?LiteralValue as string : LiteralValue.ToString());
     }
     return(DTokens.GetTokenString(Kind));
 }
Esempio n. 3
0
 public override string ToString()
 {
     if (Kind == DTokens.Identifier || Kind == DTokens.Literal)
     {
         return(val);
     }
     return(DTokens.GetTokenString(Kind));
 }
Esempio n. 4
0
 private bool Expect(byte n)
 {
     if (laKind == n)
     {
         Step();
         return(true);
     }
     else
     {
         SynErr(n, DTokens.GetTokenString(n) + " expected, " + DTokens.GetTokenString(laKind) + " found!");
     }
     return(false);
 }
Esempio n. 5
0
 private bool Expect(int n)
 {
     if (n == Identifier)
     {
         ExpectingIdentifier = true;
     }
     if (laKind == n)
     {
         Step();
         if (n == Identifier)
         {
             ExpectingIdentifier = false;
         }
         return(true);
     }
     else
     {
         SynErr(n, DTokens.GetTokenString(n) + " expected, " + DTokens.GetTokenString(laKind) + " found!");
     }
     return(false);
 }
Esempio n. 6
0
        void PushAttribute(DAttribute attr, bool BlockAttributes)
        {
            var stk = BlockAttributes?this.BlockAttributes:this.DeclarationAttributes;

            var m = attr as Modifier;

            if (m != null)
            {
                // If attr would change the accessability of an item, remove all previously found (so the most near attribute that's next to the item is significant)
                if (DTokens.IsVisibilityModifier(m.Token))
                {
                    Modifier.CleanupAccessorAttributes(stk, m.Token);
                }
                else
                {
                    Modifier.RemoveFromStack(stk, m.Token);
                }
            }

            stk.Push(attr);
        }
Esempio n. 7
0
 void SemErr(int n)
 {
     ParseErrors.Add(new ParserError(true, DTokens.GetTokenString(n) + " expected" + (t != null ? (", " + DTokens.GetTokenString(t.Kind) + " found") : ""), n, t == null ? la.Location : t.EndLocation));
 }
Esempio n. 8
0
 void SynErr(byte n)
 {
     SynErr(n, DTokens.GetTokenString(n) + " expected" + (t != null?(", " + DTokens.GetTokenString(t.Kind) + " found"):""));
 }
Esempio n. 9
0
        List <DAttribute> GetCurrentAttributeSet()
        {
            var      vis             = D_Parser.Dom.Visitors.AstElementHashingVisitor.Instance;
            var      keys            = new List <ulong>();
            var      attrs           = new List <DAttribute>();
            Modifier lastVisModifier = null;

            ulong key;
            int   i;

            foreach (var a in BlockAttributes)
            {
                // ISSUE: Theoretically, when having two identically written but semantically different UDA attributes, the first one will become overridden.
                key = a.Accept(vis);
                if ((i = keys.IndexOf(key)) > -1)
                {
                    attrs[i] = a;
                }
                else
                {
                    keys.Add(key);
                    attrs.Insert(0, a);
                }
            }

            foreach (var a in DeclarationAttributes)
            {
                key = a.Accept(vis);
                if ((i = keys.IndexOf(key)) > -1)
                {
                    attrs[i] = a;
                }
                else
                {
                    keys.Add(key);
                    attrs.Insert(0, a);
                }
            }
            DeclarationAttributes.Clear();

            for (i = attrs.Count - 1; i >= 0; i--)
            {
                var m = attrs[i] as Modifier;
                if (m != null)
                {
                    // If accessor already in attribute array, remove it
                    if (DTokens.IsVisibilityModifier(m.Token))
                    {
                        lastVisModifier = m;
                        // Temporarily remove all vis modifiers and add the last one again
                        attrs.RemoveAt(i);
                        //keys.RemoveAt(i); -- No need to touch keys anymore
                        continue;
                    }
                }
            }

            if (lastVisModifier != null)
            {
                attrs.Insert(0, lastVisModifier);
            }

            return(attrs);
        }