def add_tag_attributes(tag, tokens, start)
      i = start
      size = tokens.size
			
      while i < size
        token = tokens[i]
        if token.type != :IDENTIFIER
          expecting_but_got("IDENTIFIER", token.type, token.line, token.position)
        end
        name_or_namespace = token.text;
				
        if i == (size - 1)
          expecting_but_got(
            "\":\" or \"=\" \"LITERAL\"",
            "END OF LINE.",
            token.line,
            token.position)
        end
				
        i += 1
        token = tokens[i]
        if token.type == :COLON
          if i == (size - 1)
            expecting_but_got(
              "IDENTIFIER", "END OF LINE", token.line, token.position)
          end
					
          i += 1
          token = tokens[i]
          if token.type != :IDENTIFIER
            expecting_but_got(
              "IDENTIFIER", token.type, token.line, token.position)
          end
          name = token.text
					
          if i == (size - 1)
            expecting_but_got("\"=\"", "END OF LINE", token.line, token.position)
          end
					
          i += 1
          token = tokens[i]
          if token.type != :EQUALS
            expecting_but_got("\"=\"", token.type, token.line, token.position)
          end
					
          if i == (size - 1)
            expecting_but_got("LITERAL", "END OF LINE", token.line, token.position)
          end
					
          i += 1
          token = tokens[i]
          if !token.literal?
            expecting_but_got("LITERAL", token.type, token.line, token.position)
          end
					
          if token.type == :DATE and (i + 1) < size and tokens[i + 1].type == :TIME
            date = token.get_object_for_literal()
            time_span_with_zone = tokens[i + 1].get_object_for_literal()
						
            if time_span_with_zone.days != 0
              expecting_but_got(
                "TIME (component of date/time) in attribute value",
                "TIME SPAN",
                token.line,
                token.position)
            else
              tag.set_attribute(name_or_namespace, name, combine(date, time_span_with_zone))
            end
						
            i += 1
          else
            value = token.object_for_literal();
            if value.is_a?(TimeSpanWithZone)
              time_span_with_zone = value
							
              if time_span_with_zone.time_zone_offset
                expecting_but_got(
                  "TIME SPAN",
                  "TIME (component of date/time)",
                  token.line,
                  token.position)
              end
							
              time_span = SdlTimeSpan.new(
                time_span_with_zone.day,
                time_span_with_zone.hour,
                time_span_with_zone.min,
                time_span_with_zone.sec)
							
              tag.set_attribute(name_or_namespace, name, time_span)
            else
              tag.set_attribute(name_or_namespace, name, value);
            end
          end
        elsif token.type == :EQUALS
          if i == (size - 1)
            expecting_but_got("LITERAL", "END OF LINE", token.line, token.position)
          end
					
          i += 1
          token = tokens[i]
          if !token.literal?
            expecting_but_got("LITERAL", token.type, token.line, token.position)
          end
					
          if token.type == :DATE and (i + 1) < size and tokens[i + 1].type == :TIME
            date = token.object_for_literal()
            time_span_with_zone = tokens[i + 1].object_for_literal()
						
            if time_span_with_zone.day != 0
              expecting_but_got(
                "TIME (component of date/time) in attribute value",
                "TIME SPAN",
                token.line,
                token.position)
            end
            tag.set_attribute(name_or_namespace, combine(date, time_span_with_zone))
						
            i += 1
          else
            value = token.object_for_literal()
            if value.is_a?(TimeSpanWithZone)
              time_span_with_zone = value
              if time_span_with_zone.time_zone_offset
                expecting_but_got(
                  "TIME SPAN",
                  "TIME (component of date/time)",
                  token.line,
                  token.position)
              end
							
              time_span = SdlTimeSpan.new(
                time_span_with_zone.day,
                time_span_with_zone.hour,
                time_span_with_zone.min,
                time_span_with_zone.sec)
              tag.set_attribute(name_or_namespace, time_span)
            else
              tag.set_attribute(name_or_namespace, value);
            end			
          end
        else
          expecting_but_got(
            "\":\" or \"=\"", token.type, token.line, token.position)
        end
				
        i += 1
      end
    end
def add_tag_attributes(tag, tokens, start)
      i = start
      size = tokens.size
			
      while i < size
        token = tokens[i]
        if token.type != :IDENTIFIER
          expecting_but_got("IDENTIFIER", token.type, token.line, token.position)
        end
        name_or_namespace = token.text;
				
        if i == (size - 1)
          expecting_but_got(
            "\":\" or \"=\" \"LITERAL\"",
            "END OF LINE.",
            token.line,
            token.position)
        end
				
        i += 1
        token = tokens[i]
        if token.type == :COLON
          if i == (size - 1)
            expecting_but_got(
              "IDENTIFIER", "END OF LINE", token.line, token.position)
          end
					
          i += 1
          token = tokens[i]
          if token.type != :IDENTIFIER
            expecting_but_got(
              "IDENTIFIER", token.type, token.line, token.position)
          end
          name = token.text
					
          if i == (size - 1)
            expecting_but_got("\"=\"", "END OF LINE", token.line, token.position)
          end
					
          i += 1
          token = tokens[i]
          if token.type != :EQUALS
            expecting_but_got("\"=\"", token.type, token.line, token.position)
          end
					
          if i == (size - 1)
            expecting_but_got("LITERAL", "END OF LINE", token.line, token.position)
          end
					
          i += 1
          token = tokens[i]
          if !token.literal?
            expecting_but_got("LITERAL", token.type, token.line, token.position)
          end
					
          if token.type == :DATE and (i + 1) < size and tokens[i + 1].type == :TIME
            date = token.get_object_for_literal()
            time_span_with_zone = tokens[i + 1].get_object_for_literal()
						
            if time_span_with_zone.days != 0
              expecting_but_got(
                "TIME (component of date/time) in attribute value",
                "TIME SPAN",
                token.line,
                token.position)
            else
              tag.set_attribute(name_or_namespace, name, combine(date, time_span_with_zone))
            end
						
            i += 1
          else
            value = token.object_for_literal();
            if value.is_a?(TimeSpanWithZone)
              time_span_with_zone = value
							
              if time_span_with_zone.time_zone_offset
                expecting_but_got(
                  "TIME SPAN",
                  "TIME (component of date/time)",
                  token.line,
                  token.position)
              end
							
              time_span = SdlTimeSpan.new(
                time_span_with_zone.day,
                time_span_with_zone.hour,
                time_span_with_zone.min,
                time_span_with_zone.sec)
							
              tag.set_attribute(name_or_namespace, name, time_span)
            else
              tag.set_attribute(name_or_namespace, name, value);
            end
          end
        elsif token.type == :EQUALS
          if i == (size - 1)
            expecting_but_got("LITERAL", "END OF LINE", token.line, token.position)
          end
					
          i += 1
          token = tokens[i]
          if !token.literal?
            expecting_but_got("LITERAL", token.type, token.line, token.position)
          end
					
          if token.type == :DATE and (i + 1) < size and tokens[i + 1].type == :TIME
            date = token.object_for_literal()
            time_span_with_zone = tokens[i + 1].object_for_literal()
						
            if time_span_with_zone.day != 0
              expecting_but_got(
                "TIME (component of date/time) in attribute value",
                "TIME SPAN",
                token.line,
                token.position)
            end
            tag.set_attribute(name_or_namespace, combine(date, time_span_with_zone))
						
            i += 1
          else
            value = token.object_for_literal()
            if value.is_a?(TimeSpanWithZone)
              time_span_with_zone = value
              if time_span_with_zone.time_zone_offset
                expecting_but_got(
                  "TIME SPAN",
                  "TIME (component of date/time)",
                  token.line,
                  token.position)
              end
							
              time_span = SdlTimeSpan.new(
                time_span_with_zone.day,
                time_span_with_zone.hour,
                time_span_with_zone.min,
                time_span_with_zone.sec)
              tag.set_attribute(name_or_namespace, time_span)
            else
              tag.set_attribute(name_or_namespace, value);
            end			
          end
        else
          expecting_but_got(
            "\":\" or \"=\"", token.type, token.line, token.position)
        end
				
        i += 1
      end
    end
Add attributes to the given tag