Exemple #1
0
        void attrib(out CssConvert.CssParser.Attribute atb)
        {
            atb = new CssConvert.CssParser.Attribute();
            string quote = null;
            string ident = null;

            Expect(35);
            while (la.kind == 4)
            {
                Get();
            }
            identity(out ident);
            atb.Operand = ident;
            while (la.kind == 4)
            {
                Get();
            }
            if (StartOf(14))
            {
                switch (la.kind)
                {
                case 36:
                {
                    Get();
                    atb.Operator = AttributeOperator.Equals;
                    break;
                }

                case 37:
                {
                    Get();
                    atb.Operator = AttributeOperator.InList;
                    break;
                }

                case 38:
                {
                    Get();
                    atb.Operator = AttributeOperator.Hyphenated;
                    break;
                }

                case 39:
                {
                    Get();
                    atb.Operator = AttributeOperator.EndsWith;
                    break;
                }

                case 40:
                {
                    Get();
                    atb.Operator = AttributeOperator.BeginsWith;
                    break;
                }

                case 41:
                {
                    Get();
                    atb.Operator = AttributeOperator.Contains;
                    break;
                }
                }
                while (la.kind == 4)
                {
                    Get();
                }
                if (StartOf(3))
                {
                    identity(out ident);
                    atb.Value = ident;
                }
                else if (la.kind == 7 || la.kind == 8)
                {
                    QuotedString(out quote);
                    atb.Value = quote;
                }
                else
                {
                    SynErr(55);
                }
                while (la.kind == 4)
                {
                    Get();
                }
            }
            Expect(42);
        }
Exemple #2
0
        void simpleselector(out SimpleSelector ss)
        {
            ss = new SimpleSelector();
            string psd = null;

            CssConvert.CssParser.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;
            }
        }