Esempio n. 1
0
        void ruleset(out RuleSet rset)
        {
            rset = new RuleSet();
            Selector sel = null;
            Declaration dec = null;

            selector(out sel);
            rset.Selectors.Add(sel);
            while (la.kind == 27)
            {
                Get();
                selector(out sel);
                rset.Selectors.Add(sel);
            }
            Expect(24);
            if (StartOf(3))
            {
                declaration(out dec);
                rset.Declarations.Add(dec);
                while (la.kind == 25)
                {
                    Get();
                    if (la.val.Equals("}")) { Get(); return; }

                    declaration(out dec);
                    rset.Declarations.Add(dec);
                }
                if (la.kind == 25)
                {
                    Get();
                }
            }
            Expect(26);
        }
Esempio n. 2
0
        static string Render(RuleSet rls, int nesting)
        {
            StringBuilder txt = new StringBuilder();

            string start = "";
            for (int i = 0; i < nesting; i++)
            {
                start += "\t";
            }

            bool first = true;
            foreach (Selector sel in rls.Selectors)
            {
                if (first) { first = false; txt.Append(start); } else { txt.Append(", "); }
                txt.AppendFormat("<span class=\"selector\">{0}</span>", Render(sel));
            }
            txt.Append(" {\r\n");
            txt.Append(start);

            foreach (Declaration dec in rls.Declarations)
            {
                txt.AppendFormat("{1}<span class=\"declaration\">{0}</span>;\r\n", Render(dec), start + "\t");
            }

            txt.Append("}");

            return txt.ToString();
        }