Esempio n. 1
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(SgmlDtd.dcterm);
                PushEntity(this.current.ResolvedUri, e);
                cm = ParseContentModel(this.current.Lastchar);
                PopEntity();
            }
            else
            {
                string dc = ScanName(SgmlDtd.dcterm);
                cm.SetDeclaredContent(dc);
            }
            return(cm);
        }
Esempio n. 2
0
 void ParseModel(char cmt, ContentModel cm)
 {
     int depth = cm.CurrentDepth;
     char ch = this.current.Lastchar;
     ch = this.current.SkipWhitespace();
     while (ch != cmt || cm.CurrentDepth > depth)
     {
         if (ch == Entity.EOF)
         {
             this.current.Error("Content Model was not closed");
         }
         if (ch == '%')
         {
             Entity e = ParseParameterEntity(SgmlDtd.cmterm);
             PushEntity(this.current.ResolvedUri, e);
             ParseModel(Entity.EOF, cm);
             PopEntity();
             ch = this.current.SkipWhitespace();
         }
         else if (ch == '(')
         {
             cm.PushGroup();
             this.current.ReadChar();
             ch = this.current.SkipWhitespace();
         }
         else if (ch == ')')
         {
             ch = this.current.ReadChar();
             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();
             ch = this.current.SkipWhitespace();
         }
         else
         {
             string token;
             if (ch == '#')
             {
                 ch = this.current.ReadChar();
                 token = "#" + this.current.ScanToken(this.sb, SgmlDtd.cmterm, true);
             }
             else
             {
                 token = this.current.ScanToken(this.sb, SgmlDtd.cmterm, true);
             }
             token = token.ToUpper();
             token = this.nameTable.Add(token);
             ch = this.current.Lastchar;
             if (ch == '?' || ch == '+' || ch == '*')
             {
                 cm.PushGroup();
                 cm.AddSymbol(token);
                 cm.AddOccurrence(ch);
                 cm.PopGroup();
                 this.current.ReadChar();
                 ch = this.current.SkipWhitespace();
             }
             else
             {
                 cm.AddSymbol(token);
                 ch = this.current.SkipWhitespace();
             }
         }
     }
 }
Esempio n. 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(SgmlDtd.dcterm);
         PushEntity(this.current.ResolvedUri, e);
         cm = ParseContentModel(this.current.Lastchar);
         PopEntity();
     }
     else
     {
         string dc = ScanName(SgmlDtd.dcterm);
         cm.SetDeclaredContent(dc);
     }
     return cm;
 }
Esempio n. 4
0
        void ParseModel(char cmt, ContentModel cm)
        {
            int  depth = cm.CurrentDepth;
            char ch    = this.current.Lastchar;

            ch = this.current.SkipWhitespace();
            while (ch != cmt || cm.CurrentDepth > depth)
            {
                if (ch == Entity.EOF)
                {
                    this.current.Error("Content Model was not closed");
                }
                if (ch == '%')
                {
                    Entity e = ParseParameterEntity(SgmlDtd.cmterm);
                    PushEntity(this.current.ResolvedUri, e);
                    ParseModel(Entity.EOF, cm);
                    PopEntity();
                    ch = this.current.SkipWhitespace();
                }
                else if (ch == '(')
                {
                    cm.PushGroup();
                    this.current.ReadChar();
                    ch = this.current.SkipWhitespace();
                }
                else if (ch == ')')
                {
                    ch = this.current.ReadChar();
                    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();
                    ch = this.current.SkipWhitespace();
                }
                else
                {
                    string token;
                    if (ch == '#')
                    {
                        ch    = this.current.ReadChar();
                        token = "#" + this.current.ScanToken(this.sb, SgmlDtd.cmterm, true);
                    }
                    else
                    {
                        token = this.current.ScanToken(this.sb, SgmlDtd.cmterm, true);
                    }
                    token = token.ToUpper();
                    token = this.nameTable.Add(token);
                    ch    = this.current.Lastchar;
                    if (ch == '?' || ch == '+' || ch == '*')
                    {
                        cm.PushGroup();
                        cm.AddSymbol(token);
                        cm.AddOccurrence(ch);
                        cm.PopGroup();
                        this.current.ReadChar();
                        ch = this.current.SkipWhitespace();
                    }
                    else
                    {
                        cm.AddSymbol(token);
                        ch = this.current.SkipWhitespace();
                    }
                }
            }
        }