void directive(out Directive dir) { dir = new Directive(); Declaration dec = null; RuleSet rset = null; Expression exp = null; Directive dr = null; string ident = null; Medium m; Expect(23); dir.Name = "@"; if (la.kind == 24) { Get(); dir.Name += "-"; } identity(out ident); dir.Name += ident; switch (dir.Name.ToLower()) { case "@media": dir.Type = DirectiveType.Media; break; case "@import": dir.Type = DirectiveType.Import; break; case "@charset": dir.Type = DirectiveType.Charset; break; case "@page": dir.Type = DirectiveType.Page; break; case "@font-face": dir.Type = DirectiveType.FontFace; break; case "@namespace": dir.Type = DirectiveType.Namespace; break; default: dir.Type = DirectiveType.Other; break; } while (la.kind == 4) { Get(); } if (StartOf(4)) { if (StartOf(5)) { medium(out m); dir.Mediums.Add(m); while (la.kind == 4) { Get(); } while (la.kind == 25) { Get(); while (la.kind == 4) { Get(); } medium(out m); dir.Mediums.Add(m); while (la.kind == 4) { Get(); } } } else { expr(out exp); dir.Expression = exp; while (la.kind == 4) { Get(); } } } if (la.kind == 26) { Get(); while (la.kind == 4) { Get(); } if (StartOf(6)) { while (StartOf(1)) { if (dir.Type == DirectiveType.Page || dir.Type == DirectiveType.FontFace) { declaration(out dec); dir.Declarations.Add(dec); while (la.kind == 4) { Get(); } while (la.kind == 27) { Get(); while (la.kind == 4) { Get(); } if (la.val.Equals("}")) { Get(); return; } declaration(out dec); dir.Declarations.Add(dec); while (la.kind == 4) { Get(); } } if (la.kind == 27) { Get(); while (la.kind == 4) { Get(); } } } else if (StartOf(2)) { ruleset(out rset); dir.RuleSets.Add(rset); while (la.kind == 4) { Get(); } } else { directive(out dr); dir.Directives.Add(dr); while (la.kind == 4) { Get(); } } } } Expect(28); while (la.kind == 4) { Get(); } } else if (la.kind == 27) { Get(); while (la.kind == 4) { Get(); } } else { SynErr(50); } }
void ruleset(out RuleSet rset) { rset = new RuleSet(); Selector sel = null; Declaration dec = null; selector(out sel); rset.Selectors.Add(sel); while (la.kind == 4) { Get(); } while (la.kind == 25) { Get(); while (la.kind == 4) { Get(); } selector(out sel); rset.Selectors.Add(sel); while (la.kind == 4) { Get(); } } Expect(26); while (la.kind == 4) { Get(); } if (StartOf(3)) { declaration(out dec); rset.Declarations.Add(dec); while (la.kind == 4) { Get(); } while (la.kind == 27) { Get(); while (la.kind == 4) { Get(); } if (la.val.Equals("}")) { Get(); return; } declaration(out dec); rset.Declarations.Add(dec); while (la.kind == 4) { Get(); } } if (la.kind == 27) { Get(); while (la.kind == 4) { Get(); } } } Expect(28); while (la.kind == 4) { Get(); } }