src/tokeniser/tokeniser.c
hubbub_error hubbub_tokeniser_run(hubbub_tokeniser *tokeniser)
{
	hubbub_error cont = HUBBUB_OK;

	if (tokeniser == NULL)
		return HUBBUB_BADPARM;

	if (tokeniser->paused == true)
		return HUBBUB_PAUSED;

#if 0
#define state(x) \
		case x: \
			printf( #x "\n");
#else
#define state(x) \
		case x:
#endif

	while (cont == HUBBUB_OK) {
		switch (tokeniser->state) {
		state(STATE_DATA)
			cont = hubbub_tokeniser_handle_data(tokeniser);
			break;
		state(STATE_CHARACTER_REFERENCE_DATA)
			cont = hubbub_tokeniser_handle_character_reference_data(
					tokeniser);
			break;
		state(STATE_TAG_OPEN)
			cont = hubbub_tokeniser_handle_tag_open(tokeniser);
			break;
		state(STATE_CLOSE_TAG_OPEN)
			cont = hubbub_tokeniser_handle_close_tag_open(
					tokeniser);
			break;
		state(STATE_TAG_NAME)
			cont = hubbub_tokeniser_handle_tag_name(tokeniser);
			break;
		state(STATE_BEFORE_ATTRIBUTE_NAME)
			cont = hubbub_tokeniser_handle_before_attribute_name(
					tokeniser);
			break;
		state(STATE_ATTRIBUTE_NAME)
			cont = hubbub_tokeniser_handle_attribute_name(
					tokeniser);
			break;
		state(STATE_AFTER_ATTRIBUTE_NAME)
			cont = hubbub_tokeniser_handle_after_attribute_name(
					tokeniser);
			break;
		state(STATE_BEFORE_ATTRIBUTE_VALUE)
			cont = hubbub_tokeniser_handle_before_attribute_value(
					tokeniser);
			break;
		state(STATE_ATTRIBUTE_VALUE_DQ)
			cont = hubbub_tokeniser_handle_attribute_value_dq(
					tokeniser);
			break;
		state(STATE_ATTRIBUTE_VALUE_SQ)
			cont = hubbub_tokeniser_handle_attribute_value_sq(
					tokeniser);
			break;
		state(STATE_ATTRIBUTE_VALUE_UQ)
			cont = hubbub_tokeniser_handle_attribute_value_uq(
					tokeniser);
			break;
		state(STATE_CHARACTER_REFERENCE_IN_ATTRIBUTE_VALUE)
			cont = hubbub_tokeniser_handle_character_reference_in_attribute_value(
					tokeniser);
			break;
		state(STATE_AFTER_ATTRIBUTE_VALUE_Q)
			cont = hubbub_tokeniser_handle_after_attribute_value_q(
					tokeniser);
			break;
		state(STATE_SELF_CLOSING_START_TAG)
			cont = hubbub_tokeniser_handle_self_closing_start_tag(
					tokeniser);
			break;
		state(STATE_BOGUS_COMMENT)
			cont = hubbub_tokeniser_handle_bogus_comment(
					tokeniser);
			break;
		state(STATE_MARKUP_DECLARATION_OPEN)
			cont = hubbub_tokeniser_handle_markup_declaration_open(
					tokeniser);
			break;
		state(STATE_MATCH_COMMENT)
			cont = hubbub_tokeniser_handle_match_comment(
					tokeniser);
			break;
		case STATE_COMMENT_START:
		case STATE_COMMENT_START_DASH:
		case STATE_COMMENT:
		case STATE_COMMENT_END_DASH:
		case STATE_COMMENT_END:
			cont = hubbub_tokeniser_handle_comment(tokeniser);
			break;
		state(STATE_MATCH_DOCTYPE)
			cont = hubbub_tokeniser_handle_match_doctype(
					tokeniser);
			break;
		state(STATE_DOCTYPE)
			cont = hubbub_tokeniser_handle_doctype(tokeniser);
			break;
		state(STATE_BEFORE_DOCTYPE_NAME)
			cont = hubbub_tokeniser_handle_before_doctype_name(
					tokeniser);
			break;
		state(STATE_DOCTYPE_NAME)
			cont = hubbub_tokeniser_handle_doctype_name(
					tokeniser);
			break;
		state(STATE_AFTER_DOCTYPE_NAME)
			cont = hubbub_tokeniser_handle_after_doctype_name(
					tokeniser);
			break;

		state(STATE_MATCH_PUBLIC)
			cont = hubbub_tokeniser_handle_match_public(
					tokeniser);
			break;
		state(STATE_BEFORE_DOCTYPE_PUBLIC)
			cont = hubbub_tokeniser_handle_before_doctype_public(
					tokeniser);
			break;
		state(STATE_DOCTYPE_PUBLIC_DQ)
			cont = hubbub_tokeniser_handle_doctype_public_dq(
					tokeniser);
			break;
		state(STATE_DOCTYPE_PUBLIC_SQ)
			cont = hubbub_tokeniser_handle_doctype_public_sq(
					tokeniser);
			break;
		state(STATE_AFTER_DOCTYPE_PUBLIC)
			cont = hubbub_tokeniser_handle_after_doctype_public(
					tokeniser);
			break;
		state(STATE_MATCH_SYSTEM)
			cont = hubbub_tokeniser_handle_match_system(
					tokeniser);
			break;
		state(STATE_BEFORE_DOCTYPE_SYSTEM)
			cont = hubbub_tokeniser_handle_before_doctype_system(
					tokeniser);
			break;
		state(STATE_DOCTYPE_SYSTEM_DQ)
			cont = hubbub_tokeniser_handle_doctype_system_dq(
					tokeniser);
			break;
		state(STATE_DOCTYPE_SYSTEM_SQ)
			cont = hubbub_tokeniser_handle_doctype_system_sq(
					tokeniser);
			break;
		state(STATE_AFTER_DOCTYPE_SYSTEM)
			cont = hubbub_tokeniser_handle_after_doctype_system(
					tokeniser);
			break;
		state(STATE_BOGUS_DOCTYPE)
			cont = hubbub_tokeniser_handle_bogus_doctype(
					tokeniser);
			break;
		state(STATE_MATCH_CDATA)
			cont = hubbub_tokeniser_handle_match_cdata(
					tokeniser);
			break;
		state(STATE_CDATA_BLOCK)
			cont = hubbub_tokeniser_handle_cdata_block(
					tokeniser);
			break;
		state(STATE_NUMBERED_ENTITY)
			cont = hubbub_tokeniser_handle_numbered_entity(
					tokeniser);
			break;
		state(STATE_NAMED_ENTITY)
			cont = hubbub_tokeniser_handle_named_entity(
					tokeniser);
			break;
		}
	}

	return (cont == HUBBUB_NEEDDATA) ? HUBBUB_OK : cont;
}
/**
 * Process remaining data in the input stream
 *
 * \param tokeniser  The tokeniser instance to invoke
 * \return HUBBUB_OK on success, appropriate error otherwise
 */
Process remaining data in the input stream
\param tokeniser  The tokeniser instance to invoke
\return HUBBUB_OK on success, appropriate error otherwise
Process remaining data in the input stream \ param tokeniser The tokeniser instance to invoke \ return HUBBUB_OK on success appropriate error otherwise
hubbub_error hubbub_tokeniser_run(hubbub_tokeniser *tokeniser)
{
	hubbub_error cont = HUBBUB_OK;
	if (tokeniser == NULL)
		return HUBBUB_BADPARM;
	if (tokeniser->paused == true)
		return HUBBUB_PAUSED;
#if 0
#define state(x) \
		case x: \
			printf( #x "\n");
#else
#define state(x) \
		case x:
#endif
	while (cont == HUBBUB_OK) {
		switch (tokeniser->state) {
		state(STATE_DATA)
			cont = hubbub_tokeniser_handle_data(tokeniser);
			break;
		state(STATE_CHARACTER_REFERENCE_DATA)
			cont = hubbub_tokeniser_handle_character_reference_data(
					tokeniser);
			break;
		state(STATE_TAG_OPEN)
			cont = hubbub_tokeniser_handle_tag_open(tokeniser);
			break;
		state(STATE_CLOSE_TAG_OPEN)
			cont = hubbub_tokeniser_handle_close_tag_open(
					tokeniser);
			break;
		state(STATE_TAG_NAME)
			cont = hubbub_tokeniser_handle_tag_name(tokeniser);
			break;
		state(STATE_BEFORE_ATTRIBUTE_NAME)
			cont = hubbub_tokeniser_handle_before_attribute_name(
					tokeniser);
			break;
		state(STATE_ATTRIBUTE_NAME)
			cont = hubbub_tokeniser_handle_attribute_name(
					tokeniser);
			break;
		state(STATE_AFTER_ATTRIBUTE_NAME)
			cont = hubbub_tokeniser_handle_after_attribute_name(
					tokeniser);
			break;
		state(STATE_BEFORE_ATTRIBUTE_VALUE)
			cont = hubbub_tokeniser_handle_before_attribute_value(
					tokeniser);
			break;
		state(STATE_ATTRIBUTE_VALUE_DQ)
			cont = hubbub_tokeniser_handle_attribute_value_dq(
					tokeniser);
			break;
		state(STATE_ATTRIBUTE_VALUE_SQ)
			cont = hubbub_tokeniser_handle_attribute_value_sq(
					tokeniser);
			break;
		state(STATE_ATTRIBUTE_VALUE_UQ)
			cont = hubbub_tokeniser_handle_attribute_value_uq(
					tokeniser);
			break;
		state(STATE_CHARACTER_REFERENCE_IN_ATTRIBUTE_VALUE)
			cont = hubbub_tokeniser_handle_character_reference_in_attribute_value(
					tokeniser);
			break;
		state(STATE_AFTER_ATTRIBUTE_VALUE_Q)
			cont = hubbub_tokeniser_handle_after_attribute_value_q(
					tokeniser);
			break;
		state(STATE_SELF_CLOSING_START_TAG)
			cont = hubbub_tokeniser_handle_self_closing_start_tag(
					tokeniser);
			break;
		state(STATE_BOGUS_COMMENT)
			cont = hubbub_tokeniser_handle_bogus_comment(
					tokeniser);
			break;
		state(STATE_MARKUP_DECLARATION_OPEN)
			cont = hubbub_tokeniser_handle_markup_declaration_open(
					tokeniser);
			break;
		state(STATE_MATCH_COMMENT)
			cont = hubbub_tokeniser_handle_match_comment(
					tokeniser);
			break;
		case STATE_COMMENT_START:
		case STATE_COMMENT_START_DASH:
		case STATE_COMMENT:
		case STATE_COMMENT_END_DASH:
		case STATE_COMMENT_END:
			cont = hubbub_tokeniser_handle_comment(tokeniser);
			break;
		state(STATE_MATCH_DOCTYPE)
			cont = hubbub_tokeniser_handle_match_doctype(
					tokeniser);
			break;
		state(STATE_DOCTYPE)
			cont = hubbub_tokeniser_handle_doctype(tokeniser);
			break;
		state(STATE_BEFORE_DOCTYPE_NAME)
			cont = hubbub_tokeniser_handle_before_doctype_name(
					tokeniser);
			break;
		state(STATE_DOCTYPE_NAME)
			cont = hubbub_tokeniser_handle_doctype_name(
					tokeniser);
			break;
		state(STATE_AFTER_DOCTYPE_NAME)
			cont = hubbub_tokeniser_handle_after_doctype_name(
					tokeniser);
			break;
		state(STATE_MATCH_PUBLIC)
			cont = hubbub_tokeniser_handle_match_public(
					tokeniser);
			break;
		state(STATE_BEFORE_DOCTYPE_PUBLIC)
			cont = hubbub_tokeniser_handle_before_doctype_public(
					tokeniser);
			break;
		state(STATE_DOCTYPE_PUBLIC_DQ)
			cont = hubbub_tokeniser_handle_doctype_public_dq(
					tokeniser);
			break;
		state(STATE_DOCTYPE_PUBLIC_SQ)
			cont = hubbub_tokeniser_handle_doctype_public_sq(
					tokeniser);
			break;
		state(STATE_AFTER_DOCTYPE_PUBLIC)
			cont = hubbub_tokeniser_handle_after_doctype_public(
					tokeniser);
			break;
		state(STATE_MATCH_SYSTEM)
			cont = hubbub_tokeniser_handle_match_system(
					tokeniser);
			break;
		state(STATE_BEFORE_DOCTYPE_SYSTEM)
			cont = hubbub_tokeniser_handle_before_doctype_system(
					tokeniser);
			break;
		state(STATE_DOCTYPE_SYSTEM_DQ)
			cont = hubbub_tokeniser_handle_doctype_system_dq(
					tokeniser);
			break;
		state(STATE_DOCTYPE_SYSTEM_SQ)
			cont = hubbub_tokeniser_handle_doctype_system_sq(
					tokeniser);
			break;
		state(STATE_AFTER_DOCTYPE_SYSTEM)
			cont = hubbub_tokeniser_handle_after_doctype_system(
					tokeniser);
			break;
		state(STATE_BOGUS_DOCTYPE)
			cont = hubbub_tokeniser_handle_bogus_doctype(
					tokeniser);
			break;
		state(STATE_MATCH_CDATA)
			cont = hubbub_tokeniser_handle_match_cdata(
					tokeniser);
			break;
		state(STATE_CDATA_BLOCK)
			cont = hubbub_tokeniser_handle_cdata_block(
					tokeniser);
			break;
		state(STATE_NUMBERED_ENTITY)
			cont = hubbub_tokeniser_handle_numbered_entity(
					tokeniser);
			break;
		state(STATE_NAMED_ENTITY)
			cont = hubbub_tokeniser_handle_named_entity(
					tokeniser);
			break;
		}
	}
	return (cont == HUBBUB_NEEDDATA) ? HUBBUB_OK : cont;
}
hubbub_error hubbub_tokeniser_run ( hubbub_tokeniser * tokeniser ) { hubbub_error cont = HUBBUB_OK ; if ( tokeniser == NULL ) return HUBBUB_BADPARM ; if ( tokeniser -> paused == true ) return HUBBUB_PAUSED ; #if 0 #define state ( x )  \
		case x: \
			printf( #x "\n"); #else #define state ( x )  \
		case x: #endif while ( cont == HUBBUB_OK ) { switch ( tokeniser -> state ) { state ( STATE_DATA ) cont = hubbub_tokeniser_handle_data ( tokeniser ) ; break ; state ( STATE_CHARACTER_REFERENCE_DATA ) cont = hubbub_tokeniser_handle_character_reference_data ( tokeniser ) ; break ; state ( STATE_TAG_OPEN ) cont = hubbub_tokeniser_handle_tag_open ( tokeniser ) ; break ; state ( STATE_CLOSE_TAG_OPEN ) cont = hubbub_tokeniser_handle_close_tag_open ( tokeniser ) ; break ; state ( STATE_TAG_NAME ) cont = hubbub_tokeniser_handle_tag_name ( tokeniser ) ; break ; state ( STATE_BEFORE_ATTRIBUTE_NAME ) cont = hubbub_tokeniser_handle_before_attribute_name ( tokeniser ) ; break ; state ( STATE_ATTRIBUTE_NAME ) cont = hubbub_tokeniser_handle_attribute_name ( tokeniser ) ; break ; state ( STATE_AFTER_ATTRIBUTE_NAME ) cont = hubbub_tokeniser_handle_after_attribute_name ( tokeniser ) ; break ; state ( STATE_BEFORE_ATTRIBUTE_VALUE ) cont = hubbub_tokeniser_handle_before_attribute_value ( tokeniser ) ; break ; state ( STATE_ATTRIBUTE_VALUE_DQ ) cont = hubbub_tokeniser_handle_attribute_value_dq ( tokeniser ) ; break ; state ( STATE_ATTRIBUTE_VALUE_SQ ) cont = hubbub_tokeniser_handle_attribute_value_sq ( tokeniser ) ; break ; state ( STATE_ATTRIBUTE_VALUE_UQ ) cont = hubbub_tokeniser_handle_attribute_value_uq ( tokeniser ) ; break ; state ( STATE_CHARACTER_REFERENCE_IN_ATTRIBUTE_VALUE ) cont = hubbub_tokeniser_handle_character_reference_in_attribute_value ( tokeniser ) ; break ; state ( STATE_AFTER_ATTRIBUTE_VALUE_Q ) cont = hubbub_tokeniser_handle_after_attribute_value_q ( tokeniser ) ; break ; state ( STATE_SELF_CLOSING_START_TAG ) cont = hubbub_tokeniser_handle_self_closing_start_tag ( tokeniser ) ; break ; state ( STATE_BOGUS_COMMENT ) cont = hubbub_tokeniser_handle_bogus_comment ( tokeniser ) ; break ; state ( STATE_MARKUP_DECLARATION_OPEN ) cont = hubbub_tokeniser_handle_markup_declaration_open ( tokeniser ) ; break ; state ( STATE_MATCH_COMMENT ) cont = hubbub_tokeniser_handle_match_comment ( tokeniser ) ; break ; case STATE_COMMENT_START : case STATE_COMMENT_START_DASH : case STATE_COMMENT : case STATE_COMMENT_END_DASH : case STATE_COMMENT_END : cont = hubbub_tokeniser_handle_comment ( tokeniser ) ; break ; state ( STATE_MATCH_DOCTYPE ) cont = hubbub_tokeniser_handle_match_doctype ( tokeniser ) ; break ; state ( STATE_DOCTYPE ) cont = hubbub_tokeniser_handle_doctype ( tokeniser ) ; break ; state ( STATE_BEFORE_DOCTYPE_NAME ) cont = hubbub_tokeniser_handle_before_doctype_name ( tokeniser ) ; break ; state ( STATE_DOCTYPE_NAME ) cont = hubbub_tokeniser_handle_doctype_name ( tokeniser ) ; break ; state ( STATE_AFTER_DOCTYPE_NAME ) cont = hubbub_tokeniser_handle_after_doctype_name ( tokeniser ) ; break ; state ( STATE_MATCH_PUBLIC ) cont = hubbub_tokeniser_handle_match_public ( tokeniser ) ; break ; state ( STATE_BEFORE_DOCTYPE_PUBLIC ) cont = hubbub_tokeniser_handle_before_doctype_public ( tokeniser ) ; break ; state ( STATE_DOCTYPE_PUBLIC_DQ ) cont = hubbub_tokeniser_handle_doctype_public_dq ( tokeniser ) ; break ; state ( STATE_DOCTYPE_PUBLIC_SQ ) cont = hubbub_tokeniser_handle_doctype_public_sq ( tokeniser ) ; break ; state ( STATE_AFTER_DOCTYPE_PUBLIC ) cont = hubbub_tokeniser_handle_after_doctype_public ( tokeniser ) ; break ; state ( STATE_MATCH_SYSTEM ) cont = hubbub_tokeniser_handle_match_system ( tokeniser ) ; break ; state ( STATE_BEFORE_DOCTYPE_SYSTEM ) cont = hubbub_tokeniser_handle_before_doctype_system ( tokeniser ) ; break ; state ( STATE_DOCTYPE_SYSTEM_DQ ) cont = hubbub_tokeniser_handle_doctype_system_dq ( tokeniser ) ; break ; state ( STATE_DOCTYPE_SYSTEM_SQ ) cont = hubbub_tokeniser_handle_doctype_system_sq ( tokeniser ) ; break ; state ( STATE_AFTER_DOCTYPE_SYSTEM ) cont = hubbub_tokeniser_handle_after_doctype_system ( tokeniser ) ; break ; state ( STATE_BOGUS_DOCTYPE ) cont = hubbub_tokeniser_handle_bogus_doctype ( tokeniser ) ; break ; state ( STATE_MATCH_CDATA ) cont = hubbub_tokeniser_handle_match_cdata ( tokeniser ) ; break ; state ( STATE_CDATA_BLOCK ) cont = hubbub_tokeniser_handle_cdata_block ( tokeniser ) ; break ; state ( STATE_NUMBERED_ENTITY ) cont = hubbub_tokeniser_handle_numbered_entity ( tokeniser ) ; break ; state ( STATE_NAMED_ENTITY ) cont = hubbub_tokeniser_handle_named_entity ( tokeniser ) ; break ; } } return ( cont == HUBBUB_NEEDDATA ) ? HUBBUB_OK : cont ; }
Process remaining data in the input stream
 \param tokeniser  The tokeniser instance to invoke
 \return HUBBUB_OK on success, appropriate error otherwise
Process remaining data in the input stream \ param tokeniser The tokeniser instance to invoke \ return HUBBUB_OK on success appropriate error otherwise