Esempio n. 1
0
        void selector(out Selector sel)
        {
            sel = new Selector();
            SimpleSelector ss = null;
            Combinator?    cb = null;

            simpleselector(out ss);
            sel.SimpleSelectors.Add(ss);
            while (la.kind == 4)
            {
                Get();
            }
            while (StartOf(12))
            {
                if (la.kind == 29 || la.kind == 30 || la.kind == 31)
                {
                    if (la.kind == 29)
                    {
                        Get();
                        cb = Combinator.PrecededImmediatelyBy;
                    }
                    else if (la.kind == 30)
                    {
                        Get();
                        cb = Combinator.ChildOf;
                    }
                    else
                    {
                        Get();
                        cb = Combinator.PrecededBy;
                    }
                }
                while (la.kind == 4)
                {
                    Get();
                }
                simpleselector(out ss);
                if (cb.HasValue)
                {
                    ss.Combinator = cb.Value;
                }
                sel.SimpleSelectors.Add(ss);

                cb = null;
                while (la.kind == 4)
                {
                    Get();
                }
            }
        }
Esempio n. 2
0
        static string Render(SimpleSelector ss)
        {
            StringBuilder txt = new StringBuilder();

            if (ss.Combinator.HasValue)
            {
                switch (ss.Combinator.Value)
                {
                case ActiveWare.CSS.Combinator.PrecededImmediatelyBy: txt.Append(" <span class=\"combinator\">+</span> "); break;

                case ActiveWare.CSS.Combinator.ChildOf: txt.Append(" <span class=\"combinator\">&gt;</span> "); break;

                case ActiveWare.CSS.Combinator.PrecededBy: txt.Append(" <span class=\"combinator\">~</span> "); break;
                }
            }
            if (ss.ElementName != null)
            {
                txt.Append(ss.ElementName);
            }
            if (ss.ID != null)
            {
                txt.AppendFormat("<span class=\"id\">#{0}</span>", ss.ID);
            }
            if (ss.Class != null)
            {
                txt.AppendFormat("<span class=\"class\">.{0}</span>", ss.Class);
            }
            if (ss.Pseudo != null)
            {
                txt.AppendFormat("<span class=\"pseudo\">:{0}</span>", ss.Pseudo);
            }
            if (ss.Attribute != null)
            {
                txt.AppendFormat("<span class=\"attribute\">{0}</span>", Render(ss.Attribute));
            }
            if (ss.Function != null)
            {
                txt.AppendFormat("<span class=\"function\">{0}</span>", Render(ss.Function));
            }
            if (ss.Child != null)
            {
                txt.AppendFormat("{1}<span class=\"simpleSelector\">{0}</span>", Render(ss.Child), ss.Child.ElementName != null ? " " : "");
            }

            return(txt.ToString());
        }
Esempio n. 3
0
        void simpleselector(out SimpleSelector ss)
        {
            ss = new SimpleSelector();
            string psd = null;

            ActiveWare.CSS.Attribute atb    = null;
            SimpleSelector           parent = ss;
            string ident = null;

            if (StartOf(3))
            {
                identity(out ident);
                ss.ElementName = ident;
            }
            else if (la.kind == 32)
            {
                Get();
                ss.ElementName = "*";
            }
            else if (StartOf(13))
            {
                if (la.kind == 33)
                {
                    Get();
                    identity(out ident);
                    ss.ID = ident;
                }
                else if (la.kind == 34)
                {
                    Get();
                    identity(out ident);
                    ss.Class = ident;
                }
                else if (la.kind == 35)
                {
                    attrib(out atb);
                    ss.Attribute = atb;
                }
                else
                {
                    pseudo(out psd);
                    ss.Pseudo = psd;
                }
            }
            else
            {
                SynErr(54);
            }
            while (StartOf(13))
            {
                SimpleSelector child = new SimpleSelector();
                if (la.kind == 33)
                {
                    Get();
                    identity(out ident);
                    child.ID = ident;
                }
                else if (la.kind == 34)
                {
                    Get();
                    identity(out ident);
                    child.Class = ident;
                }
                else if (la.kind == 35)
                {
                    attrib(out atb);
                    child.Attribute = atb;
                }
                else
                {
                    pseudo(out psd);
                    child.Pseudo = psd;
                }
                parent.Child = child;
                parent       = child;
            }
        }