Example #1
0
        protected void ParseChildren(DTDElement element)
        {
            DTDContainer choiceSeq = ParseChoiceSequence();

            Token token = Scanner.Peek();

            choiceSeq.Cardinal = ParseCardinality();

            if (token.Type == Scanner.QUES)
            {
                choiceSeq.Cardinal = DTDCardinal.ZEROONE;
            }
            else if (token.Type == Scanner.ASTERISK)
            {
                choiceSeq.Cardinal = DTDCardinal.ZEROMANY;
            }
            else if (token.Type == Scanner.PLUS)
            {
                choiceSeq.Cardinal = DTDCardinal.ONEMANY;
            }
            else
            {
                choiceSeq.Cardinal = DTDCardinal.NONE;
            }

            element.Content = choiceSeq;
        }
Example #2
0
        protected DTDContainer ParseChoiceSequence()
        {
            TokenType separator = null;

            DTDContainer cs = null;

            for (;;)
            {
                DTDItem item = ParseCp();

                Token token = Scanner.Get();

                if ((token.Type == Scanner.PIPE) ||
                    (token.Type == Scanner.COMMA))
                {
                    if ((separator != null) && (separator != token.Type))
                    {
                        throw new DTDParseException(Scanner.GetUriId(),
                                                    "Can't mix separators in a choice/sequence",
                                                    Scanner.GetLineNumber(), Scanner.GetColumn());
                    }
                    separator = token.Type;

                    if (cs == null)
                    {
                        if (token.Type == Scanner.PIPE)
                        {
                            cs = new DTDChoice();
                        }
                        else
                        {
                            cs = new DTDSequence();
                        }
                    }
                    cs.Items.Add(item);
                }
                else if (token.Type == Scanner.RPAREN)
                {
                    if (cs == null)
                    {
                        cs = new DTDSequence();
                    }
                    cs.Items.Add(item);
                    return(cs);
                }
                else
                {
                    throw new DTDParseException(Scanner.GetUriId(),
                                                "Found invalid token in sequence: " +
                                                token.Type.Name, Scanner.GetLineNumber(), Scanner.GetColumn());
                }
            }
        }
Example #3
0
        public override bool Equals(object ob)
        {
            if (ob == this)
            {
                return(true);
            }
            if (!(ob is DTDContainer))
            {
                return(false);
            }

            if (!base.Equals(ob))
            {
                return(false);
            }

            DTDContainer other = (DTDContainer)ob;

            return(Items.Equals(other.Items));
        }