/**
  * Parse a name.
  *
  * @param parser The parser to use.
  * @return The name.
  */
 private static String parseName(final SimpleParser parser) {
   final StringBuilder result = new StringBuilder();
   parser.eatWhiteSpace();
   while (parser.isIdentifier()) {
     result.append(parser.readChar());
   }
   return result.toString();
 }
  /**
   * Parse parameters.
   *
   * @param line The line to parse.
   * @return The parsed values.
   */
  public static Map<String, String> parseParams(final String line) {
    final Map<String, String> result = new HashMap<String, String>();

    final SimpleParser parser = new SimpleParser(line);

    while (!parser.eol()) {
      final String name = ArchitectureParse.parseName(parser).toUpperCase();

      parser.eatWhiteSpace();
      if (!parser.lookAhead("=", false)) {
        throw new EncogError("Missing equals(=) operator.");
      } else {
        parser.advance();
      }

      final String value = ArchitectureParse.parseValue(parser);

      result.put(name.toUpperCase(), value);

      if (!parser.parseThroughComma()) {
        break;
      }
    }

    return result;
  }
  /**
   * Parse a value.
   *
   * @param parser The parser to use.
   * @return The newly parsed value.
   */
  private static String parseValue(final SimpleParser parser) {
    boolean quoted = false;
    final StringBuilder str = new StringBuilder();

    parser.eatWhiteSpace();

    if (parser.peek() == '\"') {
      quoted = true;
      parser.advance();
    }

    while (!parser.eol()) {
      if (parser.peek() == '\"') {
        if (quoted) {
          parser.advance();
          if (parser.peek() == '\"') {
            str.append(parser.readChar());
          } else {
            break;
          }
        } else {
          str.append(parser.readChar());
        }
      } else if (!quoted && (parser.isWhiteSpace() || (parser.peek() == ','))) {
        break;
      } else {
        str.append(parser.readChar());
      }
    }
    return str.toString();
  }