Parse an attribute list declaration.

<pre>
[52] AttlistDecl ::= '&lt;!ATTLIST' S Name AttDef* S? '&gt;'
</pre>

<p>
NOTE: the '&lt;!ATTLIST' has already been read.
491380
private void parseAttlistDecl() throws Exception {
        String elementName;

        requireWhitespace();
        elementName = readNmtoken(true);
        boolean white = tryWhitespace();
        while (!tryRead('>')) {
            if (!white) {
                fatal("whitespace required before attribute definition");
            }
            parseAttDef(elementName);
            white = tryWhitespace();
        }
    }
414886
def parse_GFF_attribute_string(attrStr, extra_return_first_value=False):
    
    if attrStr.endswith("\n"):
        attrStr = attrStr[:-1]
    d = {}
    first_val = "_unnamed_"
    for (i, attr) in itertools.izip(
            itertools.count(),
            _HTSeq.quotesafe_split(attrStr)):
        if _re_attr_empty.match(attr):
            continue
        if attr.count('"') not in (0, 2):
            raise ValueError(
                "The attribute string seems to contain mismatched quotes.")
        mo = _re_attr_main.match(attr)
        if not mo:
            raise ValueError("Failure parsing GFF attribute line")
        val = mo.group(2)
        if val.startswith('"') and val.endswith('"'):
            val = val[1:-1]
        d[intern(mo.group(1))] = intern(val)
        if extra_return_first_value and i == 0:
            first_val = val
    if extra_return_first_value:
        return (d, first_val)
    else:
        return d
598276
@Deprecated
    private static ListAttributeDefinition wrapAsList(final AttributeDefinition def) {
        final ListAttributeDefinition list = new ListAttributeDefinition(new SimpleListAttributeDefinition.Builder(def.getName(), def)
                .setElementValidator(def.getValidator())) {


            @Override
            public ModelNode getNoTextDescription(boolean forOperation) {
                final ModelNode model = super.getNoTextDescription(forOperation);
                setValueType(model);
                return model;
            }

            @Override
            protected void addValueTypeDescription(final ModelNode node, final ResourceBundle bundle) {
                setValueType(node);
            }

            @Override
            public void marshallAsElement(final ModelNode resourceModel, final boolean marshalDefault, final XMLStreamWriter writer) throws XMLStreamException {
                throw new RuntimeException();
            }

            @Override
            protected void addAttributeValueTypeDescription(ModelNode node, ResourceDescriptionResolver resolver, Locale locale, ResourceBundle bundle) {
                setValueType(node);
            }

            @Override
            protected void addOperationParameterValueTypeDescription(ModelNode node, String operationName, ResourceDescriptionResolver resolver, Locale locale, ResourceBundle bundle) {
                setValueType(node);
            }

            private void setValueType(ModelNode node) {
                node.get(ModelDescriptionConstants.VALUE_TYPE).set(ModelType.STRING);
            }
        };
        return list;
    }
197975
def _read_attr(attr_name):
    
    regex = attr_name + r"\s+=\s+'(.+)'"
    if sys.version_info.major == 2:
        with open('pefile.py', 'r') as f:
            match = re.search(regex, f.read())
    else:
        with open('pefile.py', 'r', encoding='utf-8') as f:
            match = re.search(regex, f.read())
    # Second item in the group is the value of attribute.
    return match.group(1)
1288031
private Object convertListToArray(List<?> rawValues, ExtendedAttributeDefinition attrDef, EvaluationContext context, boolean ignoreWarnings) throws ConfigEvaluatorException {
        // The implementation of this method is similar to convertListToVector,
        // but this method needs to handle primitive array types.  This could
        // be implemented by calling convertListToVector first, but that would
        // require boxing/unboxing the primitive values.  To avoid that, the
        // logic from the convertListToVector and convertObjectToSingleValue
        // methods is inlined for the primitive array types.

        int size = rawValues.size();
        int type = attrDef.getType();
        int i = 0;
        if (type == AttributeDefinition.BOOLEAN) {
            boolean[] retVal = new boolean[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Boolean.parseBoolean(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.BYTE) {
            byte[] retVal = new byte[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Byte.parseByte(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.CHARACTER) {
            char[] retVal = new char[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = value.charAt(0);
            }
            return retVal;
        } else if (type == AttributeDefinition.DOUBLE) {
            double[] retVal = new double[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Double.parseDouble(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.FLOAT) {
            float[] retVal = new float[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Float.parseFloat(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.INTEGER) {
            int[] retVal = new int[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Integer.parseInt(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.LONG) {
            long[] retVal = new long[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Long.parseLong(value);
            }
            return retVal;
        } else if (type == AttributeDefinition.SHORT) {
            short[] retVal = new short[size];
            for (Object rawValue : rawValues) {
                String value = resolveStringValue(rawValue, attrDef, context, ignoreWarnings);
                retVal[i++] = Short.parseShort(value);
            }
            return retVal;
        } else if (type == MetaTypeFactory.DURATION_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.MILLISECONDS, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_S_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.SECONDS, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_M_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.MINUTES, ignoreWarnings);
        } else if (type == MetaTypeFactory.DURATION_H_TYPE) {
            return convertListToDurationArray(rawValues, attrDef, context, TimeUnit.HOURS, ignoreWarnings);
        } else {
            // STRING, PID_TYPE, TOKEN_TYPE, and all other unknown/invalid types.
            return convertListToStringArray(rawValues, attrDef, context, ignoreWarnings);
        }
    }
465652
def attr_list(args):
    ''''''
    args.attributes = None
    result = attr_get(args)
    names = result.get("__header__",[])
    if names:
        names = names[1:]
    else:
        names = result.keys()
    return sorted(names)
146005
def attributes_assignments(list, wrapped = true, for_definition = false)
      if wrapped && lookahead(:exp_identifier_stripped_lookahead).nil? ||
         !wrapped && lookahead(:assignment_lookahead).nil?
        return list
      end

      return unless (argument = accept_stripped :node)

      argument = argument.to_sym

      if accept_stripped :assignment
        # Check if we have an attribute escape or not
        escaped = if accept :assignment_unescaped
                    false
                  else
                    true
                  end

        # Get the argument value if we have an assignment
        if (value = expression(false, wrapped))
          value[@options][:escaped] = escaped

          # IDs are unique, the rest of the attributes turn into arrays in
          # order to allow multiple values or identifiers
          add_attribute(list, argument, value)
        else
          Logger.error :parse, @code, @i, @j, :assignments_colon
        end
      else
        unless list[argument]
          default_value = for_definition ? 'nil' : 'true'
          list[argument] = [:expression, default_value, { escaped: false }]
        end
      end

      # If our attributes are wrapped, we allow method calls without
      # paranthesis, ruby style, therefore we need a terminator to signify
      # the expression end. If they are not wrapped (inline), we require
      # paranthesis and allow inline calls
      if wrapped
        # Accept optional comma between attributes
        accept_stripped :assignment_terminator

        # Lookahead for attributes on the current line and the next one
        if lookahead(:exp_identifier_stripped_lookahead)
          attributes_assignments list, wrapped, for_definition
        elsif lookahead_next_line(:exp_identifier_stripped_lookahead)
          accept_newline
          attributes_assignments list, wrapped, for_definition
        end
      elsif !wrapped && lookahead(:assignment_lookahead)
        attributes_assignments list, wrapped, for_definition
      end

      list
    end
855642
@Override
    public ListAttribute<? super X, ?> getList(String paramName)
    {
        PluralAttribute<? super X, ?, ?> declaredAttrib = getDeclaredPluralAttribute(paramName);

        if (isListAttribute(declaredAttrib))
        {
            return (ListAttribute<X, ?>) declaredAttrib;
        }

        declaredAttrib = getPluralAttriute(paramName);

        if (isListAttribute(declaredAttrib))
        {
            return (ListAttribute<X, ?>) declaredAttrib;
        }

        throw new IllegalArgumentException(
                "attribute of the given name and type is not present in the managed type, for name:" + paramName);
    }
1330639
def _parse(self, comp_att):
        

        errmsg = "Invalid attribute '{0}'".format(comp_att)

        if not CPEComponent.is_valid_attribute(comp_att):
            raise ValueError(errmsg)

        comp_str = self._encoded_value

        errmsg = "Invalid value of attribute '{0}': {1}".format(
            comp_att, comp_str)

        # Check part (system type) value
        if comp_att == CPEComponentSimple.ATT_PART:
            if not self._is_valid_part():
                raise ValueError(errmsg)

        # Check language value
        elif comp_att == CPEComponentSimple.ATT_LANGUAGE:
            if not self._is_valid_language():
                raise ValueError(errmsg)

        # Check edition value
        elif comp_att == CPEComponentSimple.ATT_EDITION:
            if not self._is_valid_edition():
                raise ValueError(errmsg)

        # Check other type of component value
        elif not self._is_valid_value():
            raise ValueError(errmsg)
407329
def __attrs_str(self, tag, attrs):
        
        enabled = self.whitelist.get(tag, ['*'])
        all_attrs = '*' in enabled
        items = []
        for attr in attrs:
            key = attr[0]
            value = attr[1] or ''
            if all_attrs or key in enabled:
                items.append( u'%s="%s"' % (key, value,) )
        return u' '.join(items)
1094171
def parse_fast(xmlfile, element_name, attrnames, warn=False, optional=False):
    
    prefixedAttrnames = [_prefix_keyword(a, warn) for a in attrnames]
    if optional:
        pattern = ''.join(['<%s' % element_name] +
                          ['(\\s+%s="(?P<%s>[^"]*?)")?' % a for a in zip(attrnames, prefixedAttrnames)])
    else:
        pattern = '.*'.join(['<%s' % element_name] +
                            ['%s="([^"]*)"' % attr for attr in attrnames])
    Record = namedtuple(element_name, prefixedAttrnames)
    reprog = re.compile(pattern)
    for line in open(xmlfile):
        m = reprog.search(line)
        if m:
            if optional:
                yield Record(**m.groupdict())
            else:
                yield Record(*m.groups())
121476
def _parse_attributes(self, element_name, package_class, namespace=''):
        
        return package_class(
            self._channel.find(
                './/{0}{1}'.format(namespace, element_name)
            ).attrib
        )
5780
private void parseAttributeStatements(BufferedReader br, ArrayList<String> names, ArrayList<String> types) throws IOException {
    String line;
    // Load attribute metadata
    while(true) {
      line = br.readLine();
      if(line == null) {
        throw new AbortException(ARFF_HEADER_DATA + " not found in file.");
      }
      // Skip comments and empty lines
      if(ARFF_COMMENT.reset(line).matches() || EMPTY.reset(line).matches()) {
        continue;
      }
      // Break on data statement to continue
      if(ARFF_HEADER_DATA.reset(line).matches()) {
        break;
      }
      // Expect an attribute specification
      Matcher matcher = ARFF_HEADER_ATTRIBUTE.reset(line);
      if(matcher.matches()) {
        String name = matcher.group(1);
        if(name.charAt(0) == '\'' && name.charAt(name.length() - 1) == '\'') {
          name = name.substring(1, name.length() - 1);
        }
        else if(name.charAt(0) == '"' && name.charAt(name.length() - 1) == '"') {
          name = name.substring(1, name.length() - 1);
        }
        String type = matcher.group(2);
        names.add(name);
        types.add(type);
        // logger.warning("Attribute name: " + name + " type: " + type);
        continue;
      }
      throw new AbortException("Unrecognized line: " + line);
    }
    assert (names.size() == types.size());
  }
410384
private void parseStartTag(boolean xmldecl, boolean throwOnResolveFailure) throws IOException, KriptonRuntimeException {
		if (!xmldecl) {
			read('<');
		}
		name = readName();
		attributeCount = 0;

		while (true) {
			skip();

			if (position >= limit && !fillBuffer(1)) {
				checkRelaxed(UNEXPECTED_EOF);
				return;
			}

			int c = buffer[position];

			if (xmldecl) {
				if (c == '?') {
					position++;
					read('>');
					return;
				}
			} else {
				if (c == '/') {
					degenerated = true;
					position++;
					skip();
					read('>');
					break;
				} else if (c == '>') {
					position++;
					break;
				}
			}

			String attrName = readName();

			int i = (attributeCount++) * 4;
			attributes = ensureCapacity(attributes, i + 4);
			attributes[i] = "";
			attributes[i + 1] = null;
			attributes[i + 2] = attrName;

			skip();
			if (position >= limit && !fillBuffer(1)) {
				checkRelaxed(UNEXPECTED_EOF);
				return;
			}

			if (buffer[position] == '=') {
				position++;

				skip();
				if (position >= limit && !fillBuffer(1)) {
					checkRelaxed(UNEXPECTED_EOF);
					return;
				}
				char delimiter = buffer[position];

				if (delimiter == '\'' || delimiter == '"') {
					position++;
				} else if (relaxed) {
					delimiter = ' ';
				} else {
					throw new KriptonRuntimeException("attr value delimiter missing!", true, this.getLineNumber(), this.getColumnNumber(), getPositionDescription(), null);
				}

				attributes[i + 3] = readValue(delimiter, true, throwOnResolveFailure, ValueContext.ATTRIBUTE);

				if (delimiter != ' ') {
					position++; // end quote
				}
			} else if (relaxed) {
				attributes[i + 3] = attrName;
			} else {
				checkRelaxed("Attr.value missing f. " + attrName);
				attributes[i + 3] = attrName;
			}
		}

		int sp = depth++ * 4;
		elementStack = ensureCapacity(elementStack, sp + 4);
		elementStack[sp + 3] = name;

		if (depth >= nspCounts.length) {
			int[] bigger = new int[depth + 4];
			System.arraycopy(nspCounts, 0, bigger, 0, nspCounts.length);
			nspCounts = bigger;
		}

		nspCounts[depth] = nspCounts[depth - 1];

		if (processNsp) {
			adjustNsp();
		} else {
			namespace = "";
		}

		// For consistency with Expat, add default attributes after fixing
		// namespaces.
		if (defaultAttributes != null) {
			Map<String, String> elementDefaultAttributes = defaultAttributes.get(name);
			if (elementDefaultAttributes != null) {
				for (Map.Entry<String, String> entry : elementDefaultAttributes.entrySet()) {
					if (getAttributeValue(null, entry.getKey()) != null) {
						continue; // an explicit value overrides the default
					}

					int i = (attributeCount++) * 4;
					attributes = ensureCapacity(attributes, i + 4);
					attributes[i] = "";
					attributes[i + 1] = null;
					attributes[i + 2] = entry.getKey();
					attributes[i + 3] = entry.getValue();
				}
			}
		}

		elementStack[sp] = namespace;
		elementStack[sp + 1] = prefix;
		elementStack[sp + 2] = name;
	}
631690
def parse_attribute_selector(self, sel, m, has_selector, quirks):
        """"""

        inverse = False
        op = m.group('cmp')
        case = util.lower(m.group('case')) if m.group('case') else None
        parts = [css_unescape(a) for a in m.group('ns_attr').split('|')]
        ns = ''
        is_type = False
        pattern2 = None
        if len(parts) > 1:
            ns = parts[0]
            attr = parts[1]
        else:
            attr = parts[0]
        if case:
            flags = re.I if case == 'i' else 0
        elif util.lower(attr) == 'type':
            flags = re.I
            is_type = True
        else:
            flags = 0

        if op:
            if m.group('value').startswith(('"', "'")) and not quirks:
                value = css_unescape(m.group('value')[1:-1], True)
            else:
                value = css_unescape(m.group('value'))
        else:
            value = None
        if not op:
            # Attribute name
            pattern = None
        elif op.startswith('^'):
            # Value start with
            pattern = re.compile(r'^%s.*' % re.escape(value), flags)
        elif op.startswith('$'):
            # Value ends with
            pattern = re.compile(r'.*?%s$' % re.escape(value), flags)
        elif op.startswith('*'):
            # Value contains
            pattern = re.compile(r'.*?%s.*' % re.escape(value), flags)
        elif op.startswith('~'):
            # Value contains word within space separated list
            # `~=` should match nothing if it is empty or contains whitespace,
            # so if either of these cases is present, use `[^\s\S]` which cannot be matched.
            value = r'[^\s\S]' if not value or RE_WS.search(value) else re.escape(value)
            pattern = re.compile(r'.*?(?:(?<=^)|(?<=[ \t\r\n\f]))%s(?=(?:[ \t\r\n\f]|$)).*' % value, flags)
        elif op.startswith('|'):
            # Value starts with word in dash separated list
            pattern = re.compile(r'^%s(?:-.*)?$' % re.escape(value), flags)
        elif op.startswith('!'):
            # Equivalent to `:not([attr=value])`
            pattern = re.compile(r'^%s(?:-.*)?$' % re.escape(value), flags)
            inverse = True
        else:
            # Value matches
            pattern = re.compile(r'^%s$' % re.escape(value), flags)
        if is_type and pattern:
            pattern2 = re.compile(pattern.pattern)

        # Append the attribute selector
        sel_attr = ct.SelectorAttribute(attr, ns, pattern, pattern2)
        if inverse:
            # If we are using `!=`, we need to nest the pattern under a `:not()`.
            sub_sel = _Selector()
            sub_sel.attributes.append(sel_attr)
            not_list = ct.SelectorList([sub_sel.freeze()], True, False)
            sel.selectors.append(not_list)
        else:
            sel.attributes.append(sel_attr)

        has_selector = True
        return has_selector
442177
def parseMultiAttributes(self, line):
        

        attrs = line.split(';')
        attrs = [a.strip() for a in attrs]
        attrs = filter(lambda a:len(a)>0, attrs)

        new_attrs = {}
        for a in attrs:
            k, v = a.split(':')
            k, v = [s.strip() for s in (k, v)]
            new_attrs[k] = v

        return new_attrs
157860
private Attribute parseAttribute(StreamTokenizer tokenizer) throws IOException, ParseException {
        Attribute attribute = null;

        // Get attribute name.
        getNextToken(tokenizer);
        String attributeName = tokenizer.sval;
        getNextToken(tokenizer);

        // Check if attribute is nominal.
        if (tokenizer.ttype == StreamTokenizer.TT_WORD) {

            // Attribute is real, integer, or string.
            if (tokenizer.sval.equalsIgnoreCase(ARFF_ATTRIBUTE_REAL) ||
                    tokenizer.sval.equalsIgnoreCase(ARFF_ATTRIBUTE_INTEGER) ||
                    tokenizer.sval.equalsIgnoreCase(ARFF_ATTRIBUTE_NUMERIC)) {
                attribute = new NumericAttribute(attributeName);
                readTillEOL(tokenizer);

            } else if (tokenizer.sval.equalsIgnoreCase(ARFF_ATTRIBUTE_STRING)) {
                attribute = new StringAttribute(attributeName);
                readTillEOL(tokenizer);

            } else if (tokenizer.sval.equalsIgnoreCase(ARFF_ATTRIBUTE_DATE)) {
                String format = null;
                if (tokenizer.nextToken() != StreamTokenizer.TT_EOL) {
                    if ((tokenizer.ttype != StreamTokenizer.TT_WORD) && (tokenizer.ttype != '\'') && (tokenizer.ttype != '\"')) {
                        throw new ParseException("not a valid date format", tokenizer.lineno());
                    }
                    format = tokenizer.sval;
                    readTillEOL(tokenizer);
                } else {
                    tokenizer.pushBack();
                }
                attribute = new DateAttribute(attributeName, null, format);
                readTillEOL(tokenizer);

            } else if (tokenizer.sval.equalsIgnoreCase(ARFF_ATTRIBUTE_RELATIONAL)) {
                readTillEOL(tokenizer);

            } else if (tokenizer.sval.equalsIgnoreCase(ARFF_END_SUBRELATION)) {
                getNextToken(tokenizer);

            } else {
                throw new ParseException("Invalid attribute type or invalid enumeration", tokenizer.lineno());
            }
        } else {

            // Attribute is nominal.
            List<String> attributeValues = new ArrayList<>();
            tokenizer.pushBack();

            // Get values for nominal attribute.
            if (tokenizer.nextToken() != '{') {
                throw new ParseException("{ expected at beginning of enumeration", tokenizer.lineno());
            }
            while (tokenizer.nextToken() != '}') {
                if (tokenizer.ttype == StreamTokenizer.TT_EOL) {
                    throw new ParseException("} expected at end of enumeration", tokenizer.lineno());
                } else {
                    attributeValues.add(tokenizer.sval.trim());
                }
            }

            String[] values = new String[attributeValues.size()];
            for (int i = 0; i < values.length; i++) {
                values[i] = attributeValues.get(i);
            }
            attribute = new NominalAttribute(attributeName, values);
        }

        getLastToken(tokenizer, false);
        getFirstToken(tokenizer);
        if (tokenizer.ttype == StreamTokenizer.TT_EOF) {
            throw new ParseException(PREMATURE_END_OF_FILE, tokenizer.lineno());
        }

        return attribute;
    }