private ContentModel ParseContentModel(char ch) { var cm = new ContentModel(); switch (ch) { case '(': _current.ReadChar(); ParseModel(')', cm); ch = _current.ReadChar(); if (Occurrences.Contains(ch)) { cm.AddOccurrence(ch); _current.ReadChar(); } break; case '%': { var e = ParseParameterEntity(Dcterm); PushEntity(_current.ResolvedUri, e); cm = ParseContentModel(_current.Lastchar); PopEntity(); // bugbug should be at EOF. } break; default: { var dc = ScanName(Dcterm); cm.SetDeclaredContent(dc); } break; } return(cm); }
/// <summary> /// Adds an occurrence character for this group, setting it's <see cref="Occurrence"/> value. /// </summary> /// <param name="c">The occurrence character.</param> public void AddOccurrence(char c) { if (Occurrences.Contains(c)) { Occurrence = Occurrences.FromChar(c); } Occurrence = Occurrence.Required; }
void ParseModel(char cmt, ContentModel cm) { // Called when part of the model is made up of the contents of a parameter entity var depth = cm.CurrentDepth; var ch = _current.SkipWhitespace(); while (ch != cmt || cm.CurrentDepth > depth) // the entity must terminate while inside the content model. { if (ch == Entity.EOF) { _current.Error("Content Model was not closed"); } switch (ch) { case '%': var e = ParseParameterEntity(Cmterm); PushEntity(_current.ResolvedUri, e); ParseModel(Entity.EOF, cm); PopEntity(); ch = _current.SkipWhitespace(); break; case '(': cm.PushGroup(); _current.ReadChar();// consume '(' ch = _current.SkipWhitespace(); break; case ')': ch = _current.ReadChar();// consume ')' if (Occurrences.Contains(ch)) { cm.AddOccurrence(ch); _current.ReadChar(); } if (cm.PopGroup() < depth) { _current.Error("Parameter entity cannot close a paren outside it's own scope"); } ch = _current.SkipWhitespace(); break; case '&': case '|': case ',': cm.AddConnector(ch); _current.ReadChar(); // skip connector ch = _current.SkipWhitespace(); break; default: string token; if (ch == '#') { _current.ReadChar(); token = "#" + _current.ScanToken(_sb, Cmterm, true); // since '#' is not a valid name character. } else { token = _current.ScanToken(_sb, Cmterm, true); } token = token.ToUpperInvariant(); ch = _current.Lastchar; if (Occurrences.Contains(ch)) { cm.PushGroup(); cm.AddSymbol(token); cm.AddOccurrence(ch); cm.PopGroup(); _current.ReadChar(); // skip connector ch = _current.SkipWhitespace(); } else { cm.AddSymbol(token); ch = _current.SkipWhitespace(); } break; } } }