internal override RdpPattern Compile(RelaxngGrammar grammar) { // RdpParamList rdpl = new RdpParamList (); // foreach (RelaxngParam prm in this.paramList) // rdpl.Add (prm.Compile (grammar)); RdpPattern p = null; if (this.except != null) { if (except.Patterns.Count == 0) { throw new RelaxngException(this, "data except pattern have no children."); } p = except.Patterns [0].Compile(grammar); for (int i = 1; i < except.Patterns.Count; i++) { p = new RdpChoice(p, except.Patterns [i].Compile(grammar)); } } IsCompiled = true; if (this.except != null) { return(new RdpDataExcept(new RdpDatatype(DatatypeLibrary, Type, ParamList, grammar.Provider), p)); } else { return(new RdpData(new RdpDatatype(DatatypeLibrary, Type, ParamList, grammar.Provider))); } }
private void CheckStartPatternContent(RdpPattern p) { switch (p.PatternType) { case RelaxngPatternType.Ref: CheckStartPatternContent(((RdpUnresolvedRef)p).RefPattern); break; case RelaxngPatternType.Element: break; case RelaxngPatternType.Choice: RdpChoice c = p as RdpChoice; CheckStartPatternContent(c.LValue); CheckStartPatternContent(c.RValue); break; case RelaxngPatternType.NotAllowed: break; default: // FIXME: fill line info throw new RelaxngException("Start pattern contains an invalid content pattern."); } }
internal RdpPattern makeBinary (RelaxngGrammar g) { // Flatten patterns. See 4.12. if (patterns.Count == 0) throw new RelaxngException (this, "No pattern contents."); RdpPattern p = ((RelaxngPattern) patterns [0]).Compile (g); if (patterns.Count == 1) return p; for (int i=1; i<patterns.Count; i++) { RdpPattern cp = ((RelaxngPattern) patterns [i]).Compile (g); switch (this.PatternType) { case RelaxngPatternType.Choice: p = new RdpChoice (p, cp); break; case RelaxngPatternType.Group: p = new RdpGroup (p, cp); break; case RelaxngPatternType.Interleave: p = new RdpInterleave (p, cp); break; } } return p; }