예제 #1
0
        private DothtmlNameNode ReadName(bool whitespacesBefore, bool whiteSpacesAfter, DothtmlTokenType nameTokenType)
        {
            var startIndex = CurrentIndex;

            var node = new DothtmlNameNode();

            if (whitespacesBefore)
            {
                node.WhitespacesBefore = SkipWhiteSpace();
            }

            Assert(nameTokenType);
            node.NameToken = Read();

            if (whiteSpacesAfter)
            {
                node.WhitespacesAfter = SkipWhiteSpace();
            }

            node.Tokens.Add(GetTokensFrom(startIndex));
            return(node);
        }
예제 #2
0
 public DothtmlAttributeNode(DothtmlNameNode attributeNameNode)
 {
     this.AttributeNameNode = attributeNameNode;
 }
예제 #3
0
        /// <summary>
        /// Reads the attribute.
        /// </summary>
        private DothtmlAttributeNode ReadAttribute()
        {
            var startIndex = CurrentIndex;
            var attribute  = new DothtmlAttributeNode();

            // attribute name
            DothtmlNameNode nameOrPrefix = ReadName(false, false, DothtmlTokenType.Text);

            if (Peek().Type == DothtmlTokenType.Colon)
            {
                attribute.PrefixSeparatorToken = Read();

                attribute.AttributePrefixNode = nameOrPrefix;

                attribute.AttributeNameNode = ReadName(false, false, DothtmlTokenType.Text);
            }
            else
            {
                attribute.AttributeNameNode = nameOrPrefix;
            }
            //spaces before separator belong to name
            attribute.AttributeNameNode.WhitespacesAfter = SkipWhiteSpace();


            if (Peek().Type == DothtmlTokenType.Equals)
            {
                attribute.ValueSeparatorToken = Read();

                var valueStartTokens = SkipWhiteSpace();
                var valueEndTokens   = new AggregateList <DothtmlToken>();
                // attribute value
                if (Peek().Type == DothtmlTokenType.SingleQuote || Peek().Type == DothtmlTokenType.DoubleQuote)
                {
                    var quote = Peek().Type;
                    Read();
                    valueStartTokens = valueStartTokens.AddLen(1);

                    var startingWhitespaces = SkipWhiteSpace();

                    if (Peek().Type == DothtmlTokenType.OpenBinding)
                    {
                        attribute.ValueNode = ReadBindingValue(false, true);
                    }
                    else
                    {
                        attribute.ValueNode = ReadTextValue(false, true, DothtmlTokenType.Text);
                    }
                    //we had to jump forward to decide
                    attribute.ValueNode.WhitespacesBefore = startingWhitespaces;

                    Assert(quote);
                    valueEndTokens.Add(PeekPart());
                    Read();
                }
                else
                {
                    attribute.ValueNode = ReadTextValue(false, false, DothtmlTokenType.Text);
                    //these are not part of any attribute or value
                    SkipWhiteSpace();
                }
                attribute.ValueStartTokens = valueStartTokens;
                valueEndTokens.Add(SkipWhiteSpace());
                attribute.ValueEndTokens = valueEndTokens;
            }

            attribute.Tokens.Add(GetTokensFrom(startIndex));
            return(attribute);
        }
예제 #4
0
 public DothtmlDirectiveNode(DothtmlToken directiveStartToken, DothtmlNameNode nameNode, DothtmlValueTextNode valueNode)
 {
     DirectiveStartToken = directiveStartToken;
     NameNode            = nameNode;
     ValueNode           = valueNode;
 }
예제 #5
0
 public void Visit(DothtmlNameNode name)
 {
     LastFoundNode = name;
 }
예제 #6
0
 public void Visit(DothtmlNameNode name)
 {
     LastFoundNode = name;
 }
예제 #7
0
 public DothtmlBindingNode(DothtmlToken startToken, DothtmlToken endToken, DothtmlToken separatorToken, DothtmlNameNode nameNode, DothtmlValueTextNode valueNode)
 {
     this.StartToken     = startToken;
     this.EndToken       = endToken;
     this.SeparatorToken = separatorToken;
     this.NameNode       = nameNode;
     this.ValueNode      = valueNode;
 }