WONKY



LOG | FILES | OVERVIEW


#ifndef WONKY_PARSE_TRANSLATION_C
#define WONKY_PARSE_TRANSLATION_C WONKY_PARSE_TRANSLATION_C
#include <parse_translation_unit.h>
#include <gcc_error.h>
/*
	translation-unit:
		declaration [ translation-unit ]
		function-definition [ translation-unit ]
*/
struct AST* parse_translation_unit(struct Translation_Data *translation_data)
{
	struct AST_Translation_Unit *hold;
	hold=get_translation_unit_tree();

	while(!translation_eof(translation_data))
	{
		if(is_type_name(translation_data,hold->file_scope) || kw_get(translation_data)==KW_ID)
		{
			if(chase_next_semicolon_if_needed(translation_data))
				break;
			parse_external_definition(translation_data,hold);
			if(chase_next_semicolon_if_needed(translation_data))
				break;
		}else
		{
			push_translation_error("Declaration expected %WPl",translation_data,translation_data->token_pointer);
			if(chase_next_semicolon_if_needed(translation_data))
				break;
		}
	}

	wonky_assert(is_valid_translation_unit(hold));

	return (struct AST*)hold;

}

#endif