Esempio n. 1
0
        void selector(out Model.Selector sel)
        {
            sel = new Model.Selector();
            Model.SimpleSelector ss = null;
            Model.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 = Model.Combinator.PrecededImmediatelyBy;
                    }
                    else if (la.kind == 30)
                    {
                        Get();
                        cb = Model.Combinator.ChildOf;
                    }
                    else
                    {
                        Get();
                        cb = Model.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(Model.SimpleSelector ss)
        {
            StringBuilder txt = new StringBuilder();

            if (ss.Combinator.HasValue)
            {
                switch (ss.Combinator.Value)
                {
                case breinstormin.tools.web.css.Model.Combinator.PrecededImmediatelyBy: txt.Append(" <span class=\"combinator\">+</span> "); break;

                case breinstormin.tools.web.css.Model.Combinator.ChildOf: txt.Append(" <span class=\"combinator\">&gt;</span> "); break;

                case breinstormin.tools.web.css.Model.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 Model.SimpleSelector ss)
        {
            ss = new Model.SimpleSelector();
            ss.ElementName = "";
            string psd = null;
            breinstormin.tools.web.css.Model.Attribute atb = null;
            Model.SimpleSelector parent = ss;
            string ident = null;

            if (StartOf(3)) {
                if (la.kind == 24) {
                    Get();
                    ss.ElementName += "-";
                }
                identity(out ident);
                ss.ElementName += ident;
            } else if (la.kind == 32) {
                Get();
                ss.ElementName = "*";
            } else if (StartOf(13)) {
                if (la.kind == 33) {
                    Get();
                    if (la.kind == 24) {
                        Get();
                        ss.ID = "-";
                    }
                    identity(out ident);
                    if (ss.ID == null) { ss.ID = ident; } else { ss.ID += ident; }
                } else if (la.kind == 34) {
                    Get();
                    ss.Class = "";
                    if (la.kind == 24) {
                        Get();
                        ss.Class += "-";
                    }
                    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(55);
            while (StartOf(13)) {
                Model.SimpleSelector child = new Model.SimpleSelector();
                if (la.kind == 33) {
                    Get();
                    if (la.kind == 24) {
                        Get();
                        child.ID = "-";
                    }
                    identity(out ident);
                    if (child.ID == null) { child.ID = ident; } else { child.ID += "-"; }
                } else if (la.kind == 34) {
                    Get();
                    child.Class = "";
                    if (la.kind == 24) {
                        Get();
                        child.Class += "-";
                    }
                    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;

            }
        }
Esempio n. 4
0
        void simpleselector(out Model.SimpleSelector ss)
        {
            ss             = new Model.SimpleSelector();
            ss.ElementName = "";
            string psd = null;

            breinstormin.tools.web.css.Model.Attribute atb = null;
            Model.SimpleSelector parent = ss;
            string ident = null;

            if (StartOf(3))
            {
                if (la.kind == 24)
                {
                    Get();
                    ss.ElementName += "-";
                }
                identity(out ident);
                ss.ElementName += ident;
            }
            else if (la.kind == 32)
            {
                Get();
                ss.ElementName = "*";
            }
            else if (StartOf(13))
            {
                if (la.kind == 33)
                {
                    Get();
                    if (la.kind == 24)
                    {
                        Get();
                        ss.ID = "-";
                    }
                    identity(out ident);
                    if (ss.ID == null)
                    {
                        ss.ID = ident;
                    }
                    else
                    {
                        ss.ID += ident;
                    }
                }
                else if (la.kind == 34)
                {
                    Get();
                    ss.Class = "";
                    if (la.kind == 24)
                    {
                        Get();
                        ss.Class += "-";
                    }
                    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(55);
            }
            while (StartOf(13))
            {
                Model.SimpleSelector child = new Model.SimpleSelector();
                if (la.kind == 33)
                {
                    Get();
                    if (la.kind == 24)
                    {
                        Get();
                        child.ID = "-";
                    }
                    identity(out ident);
                    if (child.ID == null)
                    {
                        child.ID = ident;
                    }
                    else
                    {
                        child.ID += "-";
                    }
                }
                else if (la.kind == 34)
                {
                    Get();
                    child.Class = "";
                    if (la.kind == 24)
                    {
                        Get();
                        child.Class += "-";
                    }
                    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;
            }
        }