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); }
public DothtmlAttributeNode(DothtmlNameNode attributeNameNode) { this.AttributeNameNode = attributeNameNode; }
/// <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); }
public DothtmlDirectiveNode(DothtmlToken directiveStartToken, DothtmlNameNode nameNode, DothtmlValueTextNode valueNode) { DirectiveStartToken = directiveStartToken; NameNode = nameNode; ValueNode = valueNode; }
public void Visit(DothtmlNameNode name) { LastFoundNode = name; }
public void Visit(DothtmlNameNode name) { LastFoundNode = name; }
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; }