Example #1
0
 void ParseModel(char cmt, ContentModel cm)
 {
     // Called when part of the model is made up of the contents of a parameter entity
     int depth = cm.CurrentDepth;
     char ch = this.current.Lastchar;
     ch = this.current.SkipWhitespace();
     while (ch != cmt || cm.CurrentDepth > depth) // the entity must terminate while inside the content model.
     {
         if (ch == Entity.EOF)
         {
             this.current.Error("Content Model was not closed");
         }
         if (ch == '%')
         {
             Entity e = ParseParameterEntity(cmterm);
             PushEntity(this.current.ResolvedUri, e);
             ParseModel(Entity.EOF, cm);
             PopEntity();
             ch = this.current.SkipWhitespace();
         }
         else if (ch == '(')
         {
             cm.PushGroup();
             this.current.ReadChar();// consume '('
             ch = this.current.SkipWhitespace();
         }
         else if (ch == ')')
         {
             ch = this.current.ReadChar();// consume ')'
             if (ch == '*' || ch == '+' || ch == '?')
             {
                 cm.AddOccurrence(ch);
                 ch = this.current.ReadChar();
             }
             if (cm.PopGroup() < depth)
             {
                 this.current.Error("Parameter entity cannot close a paren outside it's own scope");
             }
             ch = this.current.SkipWhitespace();
         }
         else if (ch == ',' || ch == '|' || ch == '&')
         {
             cm.AddConnector(ch);
             this.current.ReadChar(); // skip connector
             ch = this.current.SkipWhitespace();
         }
         else
         {
             string token;
             if (ch == '#')
             {
                 ch = this.current.ReadChar();
                 token = "#" + this.current.ScanToken(this.sb, cmterm, true); // since '#' is not a valid name character.
             }
             else
             {
                 token = this.current.ScanToken(this.sb, cmterm, true);
             }
             token = token.ToUpper();
             token = this.nameTable.Add(token);// atomize it.
             ch = this.current.Lastchar;
             if (ch == '?' || ch == '+' || ch == '*')
             {
                 cm.PushGroup();
                 cm.AddSymbol(token);
                 cm.AddOccurrence(ch);
                 cm.PopGroup();
                 this.current.ReadChar(); // skip connector
                 ch = this.current.SkipWhitespace();
             }
             else
             {
                 cm.AddSymbol(token);
                 ch = this.current.SkipWhitespace();
             }
         }
     }
 }
Example #2
0
 public ElementDecl(string name, bool sto, bool eto, ContentModel cm, string[] inclusions, string[] exclusions)
 {
     Name = name;
     StartTagOptional = sto;
     EndTagOptional = eto;
     ContentModel = cm;
     Inclusions = inclusions;
     Exclusions = exclusions;
 }
Example #3
0
 ContentModel ParseContentModel(char ch)
 {
     ContentModel cm = new ContentModel();
     if (ch == '(')
     {
         this.current.ReadChar();
         ParseModel(')', cm);
         ch = this.current.ReadChar();
         if (ch == '?' || ch == '+' || ch == '*')
         {
             cm.AddOccurrence(ch);
             this.current.ReadChar();
         }
     }
     else if (ch == '%')
     {
         Entity e = ParseParameterEntity(dcterm);
         PushEntity(this.current.ResolvedUri, e);
         cm = ParseContentModel(this.current.Lastchar);
         PopEntity(); // bugbug should be at EOF.
     }
     else
     {
         string dc = ScanName(dcterm);
         cm.SetDeclaredContent(dc);
     }
     return cm;
 }