private void analyseInstructionFormat(String line) throws AssemblerException {

		if (line.trim().length() == 0)
			return;

		foundInsFormat = true;
		line = line.trim();

		// Legit instruction format:
		// (!(space|colon))+ space* colon space* (letters|numbers)+ openBracket
		// 0-9+ closeBracket
		// (space* (letter|numbers)+ openBracket 0-9+ closeBracket)*
		boolean validInsFormat = Pattern
				.matches("[^\\s:]+\\s*:\\s*[a-zA-Z0-9]+\\([0-9]+\\)(\\s*[a-zA-Z0-9]+\\([0-9]+\\))*",
						line);

		if (!validInsFormat) {
			throw new AssemblerException(
					"InstructionFormat error: Syntax error, <instructionName> : <fieldName>(<bitLength>) expected. For example:\n"
							+ "\nopcode : op(6) d(1) s(1)");
		}

		InstructionFormat insF = new InstructionFormat();
		String[] tokens = line.split(":");
		String insName = tokens[0].trim();
		String fieldsAndValues = tokens[1].trim();
		String[] fieldTokens = fieldsAndValues.split("\\s+");

		for (String field : fieldTokens) {
			String[] fieldAndSize = field.split("\\(|\\)");
			String fieldName = fieldAndSize[0];
			int bitSize = Integer.parseInt(fieldAndSize[1]);			
			if(bitSize == 0)
				throw new AssemblerException(
						"InstructionFormat error: Can not have 0 bit field length.");
			if(insF.getFields().contains(fieldName))
				throw new AssemblerException(
						"InstructionFormat error: Field \""+fieldName+"\" defined multiple times in instruction.");
			insF.getFields().add(fieldName);
			insF.getFieldBitHash().put(fieldName, bitSize);
		} 
		
		insF.setInstructionName(insName);
		insF.setRawLineString(line.trim());
		
		if(data.getInstructionFormatHash().get(insName) != null)
			throw new AssemblerException(
					"InstructionFormat error: Instruction \""+ insName + "\" already defined");
		
		data.getInstructionFormatHash().put(insName, insF);
	}