WONKY



LOG | FILES | OVERVIEW


F diff --git a/src/frontend/parse/parse_declaration.c b/src/frontend/parse/parse_declaration.c --- a/src/frontend/parse/parse_declaration.c +++ b/src/frontend/parse/parse_declaration.c
struct identifier *id;
hold_token=(struct token_identifier*)get_next_token(translation_data);
-
+
wonky_assert(hold_token->type=KW_ID);
id=hold_token->id;
if(hold!=NULL && hold->denotation==DT_Typedef)
{
ret->type=((struct Denoted_Type*)hold)->type;
- chomp(translation_data);
return ret;
}else
{
- push_translation_error("Expected type got %WI",translation_data,id);
+ /* push_translation_error("Expected type got %WI",translation_data,id);
+ this thing is commented out because we have situations like short a;
+ that fall into this place;
+ */
+ token_ptr_unget_token(translation_data->token_pointer,
+ (struct token*)hold_token);
}
/*This was a falltrough before*/
}
{
ret->type=(struct Type*)get_basic_type(ret);
}
+
+ if(type_is_errorneus(ret->type))
+ push_translation_error("Expected type for declaration",translation_data);
+
return ret;
}
}
{
hold_middle_part=base->type;
base->type=hold_first_part;
- parse_declarator_inner(translation_data,scope,base);
- if(!rebase_type(hold_middle_part,base->type))
+ parse_direct_declarator_finish(translation_data,scope,base);
+ if(rebase_type(hold_middle_part,base->type))
{
base->type=hold_middle_part;
}else
if(get_and_check(translation_data,KW_CLOSE_CURLY))
return ;
/*TODO error*/
- push_generic_error(translation_data->program,"expected closing curly bracket from struct declaration");
+ push_translation_error("expected closing curly bracket from struct declaration",translation_data);
return;
}
}
base->has_constant_member=1;
}else
{
- push_generic_error(translation_data->program,"non object declaration in struct definition");
+ push_translation_error("non object declaration in struct definition",translation_data);
}
}else
{
wonky_free(prototype);
- push_generic_error(translation_data->program,"there is a problem with the declarator");
+ push_translation_error("there is a problem with the declarator",translation_data);
return 0;
}
if(!get_and_check(translation_data,KW_COMMA) && !check(translation_data,KW_SEMICOLON))
{
wonky_free(prototype);
- push_generic_error(translation_data->program,"semi column expected in struct declaration");
+ push_translation_error("semi column expected in struct declaration",translation_data);
return 0;
}
}
+
wonky_free(prototype);
return 1;
F diff --git a/src/frontend/parse/parse_expression.c b/src/frontend/parse/parse_expression.c --- a/src/frontend/parse/parse_expression.c +++ b/src/frontend/parse/parse_expression.c
}while(get_and_check(translation_data,KW_COMMA));
ret=get_function_expression_tree(id,&arg_list,translation_data);
- wonky_assert(arg_list.size==0);
+
+ wonky_assert(ret->type==ERROR || arg_list.size==0);
if(get_and_check(translation_data,KW_CLOSE_NORMAL))
{
F diff --git a/src/semantics/program/translation_unit.c b/src/semantics/program/translation_unit.c --- a/src/semantics/program/translation_unit.c +++ b/src/semantics/program/translation_unit.c
hold_token=get_token_from_two_adjacent_strings((struct token_string*)hold_hold_token,(struct token_string*)hold_token);
}
}
+ if(token_pointer->print_gotten_tokens)
+ wonky_printf("token_ptr_get_token_under_pointer: %Wt\n",hold_token);
return hold_token;
}
struct token* token_ptr_get_token_under_pointer_inner(struct Token_Pointer *token_pointer)
ret->state=TOKEN_POINTER_STATE_NORMAL;
ret->is_in_conditional_directive=0;
ret->ungeted_tokens=wonky_malloc(sizeof(struct Queue));
+ ret->print_gotten_tokens=0;
Stack_Init(ret->call_stack);
return;
}
- if(hold_argument_node!=NULL && number_of_tokens_in_argument!=0)
+ if(hold_argument_node!=NULL && hold_argument_node->prev!=NULL && number_of_tokens_in_argument!=0)
{
push_token_pointer_error(ptr,"Too few arguments given to functionlike macro");
return;
{
wonky_free(context);
}
+
+ void token_ptr_start_printing_gotten_tokens(struct Token_Pointer *ptr)
+ {
+ ptr->print_gotten_tokens=1;
+ }
+ void token_ptr_stop_printing_gotten_tokens(struct Token_Pointer *ptr)
+ {
+ ptr->print_gotten_tokens=0;
+ }
#endif
F diff --git a/src/semantics/program/translation_unit.h b/src/semantics/program/translation_unit.h --- a/src/semantics/program/translation_unit.h +++ b/src/semantics/program/translation_unit.h
struct Queue *ungeted_tokens;
unsigned int next_barrier_number;
+ _Bool print_gotten_tokens;
};
struct Preprocessing_Translation_Unit* get_preprocessing_translation_unit(struct Source_File *source);
void delete_preprocessing_translation_unit_but_not_the_tokens(struct Preprocessing_Translation_Unit *unit);
void push_token_into_preprocessing_translation_unit(struct Preprocessing_Translation_Unit *unit,struct token *token);
- struct token* token_ptr_get_token_under_pointer_in_preprocessing_directive(struct Token_Pointer *token_pointer);
+ //struct token* token_ptr_get_token_under_pointer_in_preprocessing_directive(struct Token_Pointer *token_pointer);
struct token* token_ptr_get_token_under_pointer(struct Token_Pointer *token_pointer);
struct token* token_ptr_get_token_under_pointer_inner(struct Token_Pointer *token_pointer);
struct token* token_ptr_check_next_normal_token(struct Token_Pointer *token_pointer);
void token_ptr_jump_to_functionlike_macro_argument(struct Token_Pointer *ptr,struct functionlike_define_directive_argument *arg);
void token_ptr_jump_to_first(struct Token_Pointer *ptr,struct Queue *queue,_Bool is_file_inclusion);
void delete_token_ptr_context(struct Token_Pointer_Context *context);
+
+
+ void token_ptr_start_printing_gotten_tokens(struct Token_Pointer *ptr);
+ void token_ptr_stop_printing_gotten_tokens(struct Token_Pointer *ptr);
+
#endif
F diff --git a/src/semantics/value/type.c b/src/semantics/value/type.c --- a/src/semantics/value/type.c +++ b/src/semantics/value/type.c
ret->members=wonky_malloc(sizeof(struct Queue));
Queue_Init(ret->members);
- ret->inner_namespace=(struct Normal_Scope*)get_normal_scope(NULL,BLOCK_SCOPE);
+ ret->inner_namespace=(struct Normal_Scope*)get_normal_scope(scope,BLOCK_SCOPE);
ret->is_finished=0;
ret->has_constant_member=0;
ret->id=id;
ret->sign=prototype->sign;
+ /*This is here to check for typless declarations for example:
+ * a;*/
+ if(prototype->specifier==TS_NONE && prototype->constraint==TC_NONE
+ && prototype->sign==TSIGN_NONE)
+ {
+ return get_type_error((struct Type*)ret);
+ }
+
if(prototype->specifier==TS_NONE)
{
ret->specifier=TS_INT;
}else
{
ret->specifier=prototype->specifier;
-
}
switch(ret->specifier)
}
return 0;
}
+ _Bool type_is_errorneus(struct Type *type)
+ {
+ return type==NULL || type->specifier==TS_ERROR;
+ }
#endif
F diff --git a/src/semantics/value/type.h b/src/semantics/value/type.h --- a/src/semantics/value/type.h +++ b/src/semantics/value/type.h
_Bool type_is_constant(struct Type *type);
_Bool type_is_volatile(struct Type *type);
+ _Bool type_is_errorneus(struct Type *type);
+
int type_get_integer_conversion_rank(struct Type_Basic *type);
F diff --git a/src/syntax/source_file.c b/src/syntax/source_file.c --- a/src/syntax/source_file.c +++ b/src/syntax/source_file.c
.length=0,
.src=&(struct Source_File){.type=SOURCE_TEXT_PARTIAL_TEXT,.src_name=&start_of_file_name,.src="",.src_name=0},
};
+ const char stdargs_builtin[] =
+ "#ifndef __WONKY_INTERNAL_STDARGS_H\n"
+ "#define __WONKY_INTERNAL_STDARGS_H __WONKY_INTERNAL_STDARGS_H\n"
+ "\n"
+ "#define va_start(v,l) \n"
+ "#define va_end(v) \n"
+ "#define va_arg(v,l) \n"
+ "#define va_copy(d,s) \n"
+ "\n"
+ "#endif\n";
struct Source_File* get_source_file_from_string(char *filename,size_t filename_size,struct Program *program)
{
struct Source_File *ret;
ret->src_size=0;
ret->src_name=NULL;
+ if(gstrn_cmp(filename,"stdarg.h",filename_size))
+ {
+ ret->src=gstrncpy(stdargs_builtin,sizeof(stdargs_builtin));
+ ret->src_size=sizeof(stdargs_builtin)-1;
+ ret->src_name=get_source_name(filename);
+ return ret;
+ }
+
for(selected_base_directory=0;selected_base_directory<wonky_default_include_paths_size;++selected_base_directory)
{
hold_constructed_filename=gstr_append(
F diff --git a/src/syntax/token/token.c b/src/syntax/token/token.c --- a/src/syntax/token/token.c +++ b/src/syntax/token/token.c
*hold_err=wonky_string_make();
va_start(args,program);
- wonky_string_vprintf(&hold_err,msg,args);
+ wonky_string_vprintf(hold_err,msg,args);
va_end(args);
ret=wonky_malloc(sizeof(struct token_error));