Exemple #1
0
 public virtual bool ParseAttribute(Attribute a)
 {
     a.Clear();
     string tag = string.Empty;
     if (a.ParentNode != null && a.ParentNode.ParentNode != null && a.ParentNode.ParentNode is Tag) tag = ((Tag)(a.ParentNode.ParentNode)).FullName;
     a.Spacer.Value = string.Empty;
     if (CurrentToken.Class == TokenClass.Identifier) {
         a.NameToken.Read();
         if (CurrentToken.Class == TokenClass.Equals) {
             a.HasValue = true;
             a.EqualsToken.Read();
             if (CurrentToken.Class == TokenClass.String || CurrentToken.Class == TokenClass.Identifier) {
                 a.ValueToken.Read();
                 return true;
             } else {
                 Error("Attribute in {0}: string value or identifier expected.", tag);
                 a.ValueToken.Class = TokenClass.String; a.ValueToken.Value = string.Empty;
             }
         } else {
             // Error("Attribute in {0}: equal sign expected.", tag);
             a.EqualsToken.Class = TokenClass.Equals;
             a.ValueToken.Class = TokenClass.String; a.ValueToken.Value = string.Empty;
             a.HasValue = false;
         }
     } else {
         Error("Attribute in {0}: attribute identifier expected.", tag);
         a.NameToken.Class = TokenClass.Identifier; a.NameToken.Value = "_error" + a.Index.ToString();
     }
     SkipTo(TokenClass.TagStart, TokenClass.Identifier, TokenClass.TagEnd, TokenClass.SingleTagEnd);
     return false;
 }