public static void parseProtocol(BufferedReader r) throws IOException {
		String line;
		Map<String, List<Integer>> map = new HashMap<String, List<Integer>>();

		while ((line = r.readLine()) != null) {
			line = line.trim();
			LinkedList<String> parts = new LinkedList<String>(Arrays.asList(line.split(" ")));
			String locString = next(parts);
			if (locString == null) {
				System.out.println(line);
				continue;
			}
			List<Integer> locs = parseLocs(locString);

			String out = null;

			String next = next(parts);
			if (next == null)
				continue;

			if (next.equals("ea")) {
				out = "new ExtraAttributeReader(";
				locs.clear();
			} else {
				parts.addFirst(next);
				String extractors = getExtractors(parts);
				out = String.format("new BasicProtocol(%s, ", extractors);
			}
			if (map.containsKey(out)) {
				map.get(out).addAll(locs);
			} else {
				map.put(out, locs);
			}
		}
		for (Entry<String, List<Integer>> entry : map.entrySet()) {
			System.out.printf("%s%s).addSelfToGroup(protocol);\n", entry.getKey().replaceAll("XX[0-9]+XX", ""),
					stringifyCollection(entry.getValue()));
		}
	}