#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)
{
parse_external_definition(translation_data,hold);
if(has_new_errors(translation_data))
{
if(translation_data->program->continue_to_parse)
chase_next_semicolumn(translation_data);
else
break;
}
}else
{
push_translation_error("declaration expected",translation_data);
chase_next_semicolumn(translation_data);
}
}
wonky_assert(is_valid_translation_unit(hold));
return (struct AST*)hold;
}
#endif