⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sgmldtd.cs

📁 Freetextbox是优秀的在线编辑器
💻 CS
📖 第 1 页 / 共 2 页
字号:
            {
                string text2 = text1.ToUpper();
                text2 = this.nameTable.Add(text1);
                this.elements.Add(text2, new ElementDecl(text2, flag1, flag2, model1, textArray3, textArray2));
            }
        }

        private void ParseEntity()
        {
            string text2;
            char ch1 = this.current.SkipWhitespace();
            bool flag1 = ch1 == '%';
            if (flag1)
            {
                this.current.ReadChar();
                ch1 = this.current.SkipWhitespace();
            }
            string text1 = this.current.ScanToken(this.sb, SgmlDtd.WhiteSpace, true);
            text1 = this.nameTable.Add(text1);
            ch1 = this.current.SkipWhitespace();
            Entity entity1 = null;
            if ((ch1 == '"') || (ch1 == '\''))
            {
                text2 = this.current.ScanLiteral(this.sb, ch1);
                entity1 = new Entity(text1, text2);
            }
            else
            {
                string text3 = null;
                string text4 = null;
                string text5 = this.current.ScanToken(this.sb, SgmlDtd.WhiteSpace, true);
                if (Entity.IsLiteralType(text5))
                {
                    ch1 = this.current.SkipWhitespace();
                    text2 = this.current.ScanLiteral(this.sb, ch1);
                    new Entity(text1, text2).SetLiteralType(text5);
                }
                else
                {
                    text4 = text5;
                    if (text4 == "PUBLIC")
                    {
                        ch1 = this.current.SkipWhitespace();
                        if ((ch1 == '"') || (ch1 == '\''))
                        {
                            text3 = this.current.ScanLiteral(this.sb, ch1);
                        }
                        else
                        {
                            this.current.Error("Expecting public identifier literal but found '{0}'", ch1);
                        }
                    }
                    else if (text4 != "SYSTEM")
                    {
                        this.current.Error("Invalid external identifier '{0}'.  Expecing 'PUBLIC' or 'SYSTEM'.", text4);
                    }
                    string text6 = null;
                    ch1 = this.current.SkipWhitespace();
                    if ((ch1 == '"') || (ch1 == '\''))
                    {
                        text6 = this.current.ScanLiteral(this.sb, ch1);
                    }
                    else if (ch1 != '>')
                    {
                        this.current.Error("Expecting system identifier literal but found '{0}'", ch1);
                    }
                    entity1 = new Entity(text1, text3, text6, this.current.Proxy);
                }
            }
            ch1 = this.current.SkipWhitespace();
            if (ch1 == '-')
            {
                ch1 = this.ParseDeclComments();
            }
            if (ch1 != '>')
            {
                this.current.Error("Expecting end of entity declaration '>' but found '{0}'", ch1);
            }
            if (flag1)
            {
                this.pentities.Add(entity1.Name, entity1);
            }
            else
            {
                this.entities.Add(entity1.Name, entity1);
            }
        }

        private void ParseIgnoreSection()
        {
            int num1 = this.current.Line;
            char ch1 = this.current.SkipWhitespace();
            if (ch1 != '[')
            {
                this.current.Error("Expecting '[' but found {0}", ch1);
            }
            this.current.ScanToEnd(this.sb, "Conditional Section", "]]>");
        }

        private void ParseIncludeSection()
        {
            throw new NotImplementedException("Include Section");
        }

        private void ParseMarkedSection()
        {
            this.current.ReadChar();
            string text1 = this.ScanName("[");
            if (text1 == "INCLUDE")
            {
                this.ParseIncludeSection();
            }
            else if (text1 == "IGNORE")
            {
                this.ParseIgnoreSection();
            }
            else
            {
                this.current.Error("Unsupported marked section type '{0}'", text1);
            }
        }

        private void ParseMarkup()
        {
            string text1;
            char ch1 = this.current.ReadChar();
            if (ch1 != '!')
            {
                this.current.Error("Found '{0}', but expecing declaration starting with '<!'");
                return;
            }
            ch1 = this.current.ReadChar();
            switch (ch1)
            {
                case '-':
                    ch1 = this.current.ReadChar();
                    if (ch1 != '-')
                    {
                        this.current.Error("Expecting comment '<!--' but found {0}", ch1);
                    }
                    this.current.ScanToEnd(this.sb, "Comment", "-->");
                    return;

                case '[':
                    this.ParseMarkedSection();
                    return;

                default:
                    text1 = this.current.ScanToken(this.sb, SgmlDtd.WhiteSpace, true);
                    switch (text1)
                    {
                        case "ENTITY":
                            this.ParseEntity();
                            goto Label_011C;

                        case "ELEMENT":
                            this.ParseElementDecl();
                            goto Label_011C;

                        case "ATTLIST":
                            this.ParseAttList();
                            goto Label_011C;
                    }
                    break;
            }
            this.current.Error("Invalid declaration '<!{0}'.  Expecting 'ENTITY', 'ELEMENT' or 'ATTLIST'.", text1);
        Label_011C:;
        }

        private void ParseModel(char cmt, ContentModel cm)
        {
            int num1 = cm.CurrentDepth;
            char ch1 = this.current.Lastchar;
            ch1 = this.current.SkipWhitespace();
            while ((ch1 != cmt) || (cm.CurrentDepth > num1))
            {
                if (ch1 == 0xffff)
                {
                    this.current.Error("Content Model was not closed");
                }
                if (ch1 == '%')
                {
                    Entity entity1 = this.ParseParameterEntity(SgmlDtd.cmterm);
                    this.PushEntity(this.current.ResolvedUri, entity1);
                    this.ParseModel(0xffff, cm);
                    this.PopEntity();
                    ch1 = this.current.SkipWhitespace();
                }
                else if (ch1 == '(')
                {
                    cm.PushGroup();
                    this.current.ReadChar();
                    ch1 = this.current.SkipWhitespace();
                }
                else if (ch1 == ')')
                {
                    ch1 = this.current.ReadChar();
                    if (((ch1 == '*') || (ch1 == '+')) || (ch1 == '?'))
                    {
                        cm.AddOccurrence(ch1);
                        ch1 = this.current.ReadChar();
                    }
                    if (cm.PopGroup() < num1)
                    {
                        this.current.Error("Parameter entity cannot close a paren outside it's own scope");
                    }
                    ch1 = this.current.SkipWhitespace();
                }
                else if (((ch1 == ',') || (ch1 == '|')) || (ch1 == '&'))
                {
                    cm.AddConnector(ch1);
                    this.current.ReadChar();
                    ch1 = this.current.SkipWhitespace();
                }
                else
                {
                    string text1;
                    if (ch1 == '#')
                    {
                        ch1 = this.current.ReadChar();
                        text1 = "#" + this.current.ScanToken(this.sb, SgmlDtd.cmterm, true);
                    }
                    else
                    {
                        text1 = this.current.ScanToken(this.sb, SgmlDtd.cmterm, true);
                    }
                    text1 = text1.ToUpper();
                    text1 = this.nameTable.Add(text1);
                    ch1 = this.current.Lastchar;
                    if (((ch1 == '?') || (ch1 == '+')) || (ch1 == '*'))
                    {
                        cm.PushGroup();
                        cm.AddSymbol(text1);
                        cm.AddOccurrence(ch1);
                        cm.PopGroup();
                        this.current.ReadChar();
                        ch1 = this.current.SkipWhitespace();
                    }
                    else
                    {
                        cm.AddSymbol(text1);
                        ch1 = this.current.SkipWhitespace();
                    }
                }
            }
        }

        private string[] ParseNameGroup(char ch, bool nmtokens)
        {
            ArrayList list1 = new ArrayList();
            if (ch == '(')
            {
                ch = this.current.ReadChar();
                ch = this.current.SkipWhitespace();
                while (ch != ')')
                {
                    ch = this.current.SkipWhitespace();
                    if (ch == '%')
                    {
                        Entity entity1 = this.ParseParameterEntity(SgmlDtd.ngterm);
                        this.PushEntity(this.current.ResolvedUri, entity1);
                        this.ParseNameList(list1, nmtokens);
                        this.PopEntity();
                        ch = this.current.Lastchar;
                    }
                    else
                    {
                        string text1 = this.current.ScanToken(this.sb, SgmlDtd.ngterm, nmtokens);
                        text1 = text1.ToUpper();
                        string text2 = this.nameTable.Add(text1);
                        list1.Add(text2);
                    }
                    ch = this.current.SkipWhitespace();
                    if ((ch == '|') || (ch == ','))
                    {
                        ch = this.current.ReadChar();
                    }
                }
                this.current.ReadChar();
            }
            else
            {
                string text3 = this.current.ScanToken(this.sb, SgmlDtd.WhiteSpace, nmtokens);
                text3 = text3.ToUpper();
                text3 = this.nameTable.Add(text3);
                list1.Add(text3);
            }
            return (string[]) list1.ToArray(typeof(string));
        }

        private void ParseNameList(ArrayList names, bool nmtokens)
        {
            char ch1 = this.current.Lastchar;
            ch1 = this.current.SkipWhitespace();
            while (ch1 != 0xffff)
            {
                if (ch1 == '%')
                {
                    Entity entity1 = this.ParseParameterEntity(SgmlDtd.ngterm);
                    this.PushEntity(this.current.ResolvedUri, entity1);
                    this.ParseNameList(names, nmtokens);
                    this.PopEntity();
                    ch1 = this.current.Lastchar;
                }
                else
                {
                    string text1 = this.current.ScanToken(this.sb, SgmlDtd.ngterm, true);
                    text1 = text1.ToUpper();
                    text1 = this.nameTable.Add(text1);
                    names.Add(text1);
                }
                ch1 = this.current.SkipWhitespace();
                if (ch1 == '|')
                {
                    ch1 = this.current.ReadChar();
                    ch1 = this.current.SkipWhitespace();
                }
            }
        }

        private Entity ParseParameterEntity(string term)
        {
            char ch1 = this.current.ReadChar();
            string text1 = this.current.ScanToken(this.sb, ";" + term, false);
            text1 = this.nameTable.Add(text1);
            if (this.current.Lastchar == ';')
            {
                this.current.ReadChar();
            }
            return this.GetParameterEntity(text1);
        }

        private void PopEntity()
        {
            if (this.current != null)
            {
                this.current.Close();
            }
            if (this.current.Parent != null)
            {
                this.current = this.current.Parent;
            }
            else
            {
                this.current = null;
            }
        }

        private void PushEntity(Uri baseUri, Entity e)
        {
            e.Open(this.current, baseUri);
            this.current = e;
            this.current.ReadChar();
        }

        private string ScanName(string term)
        {
            char ch1 = this.current.SkipWhitespace();
            if (ch1 == '%')
            {
                Entity entity1 = this.ParseParameterEntity(term);
                ch1 = this.current.Lastchar;
                if (!entity1.Internal)
                {
                    throw new NotSupportedException("External parameter entity resolution");
                }
                return entity1.Literal.Trim();
            }
            return this.current.ScanToken(this.sb, term, true);
        }


        public XmlNameTable NameTable
        {
            get
            {
                return this.nameTable;
            }
        }


        private static string cmterm;
        private Entity current;
        private static string dcterm;
        private Hashtable elements;
        private Hashtable entities;
        public string Name;
        private XmlNameTable nameTable;
        private static string ngterm;
        private Hashtable pentities;
        private static string peterm;
        private StringBuilder sb;
        private static string WhiteSpace;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -