public void prepare(CharSequence exp)
			throws ParseException {
		algorithm.clear();

		final int length = exp.length();

		NodeDefinition current_def = null;
		StringBuilder buffer = new StringBuilder();

		for (int i = 0; i < length; i++) {
			char current_char = exp.charAt(i);

			if (current_def == null) {
				/*
				 * Trying to find a compatible node
				 */
				try {
					current_def = nodeFactory.getNodeDefenition(current_char);
					buffer.append(current_char);
				} catch (NodeTypeIrresolvableException ignored) {}

			} else {

				/*
				 * If current node is still compatible, continuing to append to it.
				 */
				if (current_def.compatibleAsBody(current_char))
					buffer.append(current_char);

				/*
				 * Otherwise, trying to find a compatible definition.
				 *
				 * If fail, clearing buffers and repeating cycle with no definition.
				 *
				 */
				else {
					try {
						current_def = nodeFactory.getNodeDefinition(buffer.charAt(0), current_char);
					} catch (NodeTypeIrresolvableException e) {
						algorithm.add(current_def.instance(buffer));
						buffer = new StringBuilder();
						current_def = null;
						i--;
					}
				}

			}

		}

		if (buffer.length() > 0 && current_def != null)
			algorithm.add(current_def.instance(buffer));

	}