Ejemplo n.º 1
0
        protected ParsedNode ParseNode()
        {
            ExpectToken("Begin");
            var sectionType = ReadToken();

            ParsedPropertyBag     attributeBag = ReadAttributeList();
            List <ParsedNode>     childNodes   = new List <ParsedNode>();
            List <ParsedProperty> propertyList = new List <ParsedProperty>();

            MoveToNextLine();

            while (!ReachedEndOfDocument())
            {
                SkipWhitespace();

                string token = PeekToken();

                if (token == "Begin")
                {
                    childNodes.Add(ParseNode());
                }
                else if (token == "End")
                {
                    ExpectToken("End");
                    ExpectToken(sectionType);

                    MoveToNextLine();

                    break;
                }
                else if (token == "CustomProperties")
                {
                    // FIXME: can't find an example where this is used and it breaks our parser
                    MoveToNextLine();
                }
                else
                {
                    ParsedProperty property = ReadProperty(sectionType, propertyList);

                    if (property != null)
                    {
                        propertyList.Add(property);
                    }
                }
            }

            childNodes = PostProcessNodes(childNodes.ToArray());

            return(new ParsedNode(
                       sectionType,
                       new ParsedNodeBag(childNodes.ToArray()),
                       attributeBag,
                       new ParsedPropertyBag(propertyList.ToArray())
                       ));
        }
Ejemplo n.º 2
0
        public ParsedPropertyBag ReadAttributeList()
        {
            List <ParsedProperty> attributeList = new List <ParsedProperty>();

            while (!ReachedEndOfDocument() && !IsEndOfLine(PeekCharacter()))
            {
                ParsedProperty property = ReadAttribute();

                if (property == null)
                {
                    break;
                }

                attributeList.Add(property);
            }

            return(new ParsedPropertyBag(attributeList.ToArray()));
        }
        public bool HasPropertyWithValue(string name, string value)
        {
            ParsedProperty property = FindProperty(name);

            return(null != property && property.Value == value);
        }