WONKY



LOG | FILES | OVERVIEW


F diff --git a/src/environment/error/gcc_error.c b/src/environment/error/gcc_error.c --- a/src/environment/error/gcc_error.c +++ b/src/environment/error/gcc_error.c
line,column,filename,filename_size,fmt,args);
s=wonky_string_stream(hold->message);
wonky_fseek(&s,0,SEEK_END);
- wonky_fprintf(&s,"%WIC",translation_data->token_pointer);
+ wonky_fprintf(&s,"%WPl%WIC",translation_data->token_pointer,translation_data->token_pointer);
Queue_Push(translation_data->program->errors,hold);
wonky_string_stream_delete(&s);
}
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
{
/*TODO error*/
Queue_Push(where_to_push_objects,get_declaration_error_tree(hold));
- push_translation_error("declaration expected",translation_data);
+ push_translation_error("declaration expected",translation_data,translation_data->token_pointer);
/*search for end of erronous declaration*/
break;
F diff --git a/src/frontend/parse/parse_translation_unit.c b/src/frontend/parse/parse_translation_unit.c --- a/src/frontend/parse/parse_translation_unit.c +++ b/src/frontend/parse/parse_translation_unit.c
}
}else
{
- push_translation_error("declaration expected",translation_data);
+ push_translation_error("XX declaration expected [%WPl]",translation_data,translation_data->token_pointer);
chase_next_semicolumn(translation_data);
}
}
F diff --git a/src/misc/print.c b/src/misc/print.c --- a/src/misc/print.c +++ b/src/misc/print.c
void print_token(struct wonky_stream *out,struct token *token)
{
+
wonky_fprintf(out,"[TOKEN %WSl: ",token->delta->location);
print_token_text(out,token);
wonky_fprintf(out,"]\n");
F diff --git a/src/misc/wonky_stream.c b/src/misc/wonky_stream.c --- a/src/misc/wonky_stream.c +++ b/src/misc/wonky_stream.c
wonky_write(s,hold->filename,hold->filename_size);
wonky_fprintf(s,":%zu",hold->line+1);
print_line=1;
+ }else if(hold->executed_macro_id)
+ {
+ if(print_line)
+ wonky_write(s,"\n",1);
+ wonky_fprintf(s,"\tExpanded from %WI %WSl",hold->executed_macro_id,hold->executed_macro_id->last_defined_macro_with_this_id->delta->location);
+ print_line=1;
}
}
}
break;
+ case WONKY__CONVERSION_WONKY_TOKEN_POINTER_LINE:
+ {
+ struct Token_Pointer *tp=va_arg(args,struct Token_Pointer*);
+ struct Token_Pointer_Context *ctx;
+ wonky_assert(tp && tp->context);
+
+ if(tp->context->ungeted_tokens && tp->context->ungeted_tokens->size>0)
+ {
+ wonky_assert(tp->context->ungeted_tokens->first &&
+ tp->context->ungeted_tokens->first->data);
+ wonky_fprintf(s,"\n\t> %Wtl",tp->context->ungeted_tokens->first->data);
+ }else if(!tp->context->executed_macro_id && tp->context->current_token_node)
+ {
+ wonky_assert(tp->context->current_token_node->data);
+ wonky_fprintf(s,"\n\t> %Wtl",tp->context->current_token_node->data);
+ }else
+ {
+ for(struct Stack_Node *it=tp->call_stack->first;it;it=it->next)
+ {
+ wonky_assert(it && it->data);
+ ctx=it->data;
+ if(ctx->ungeted_tokens && ctx->ungeted_tokens->size>0)
+ {
+ wonky_assert(ctx->ungeted_tokens->first &&
+ ctx->ungeted_tokens->first->data);
+ wonky_fprintf(s,"\n\t> %Wtl",ctx->ungeted_tokens->first->data);
+ break;
+ }else if(!ctx->executed_macro_id && ctx->current_token_node)
+ {
+ wonky_assert(ctx->current_token_node->data);
+ wonky_fprintf(s,"\n\t> %Wtl",ctx->current_token_node->data);
+ break;
+ }
+ }
+ }
+ }
+ break;
case WONKY__CONVERSION_WONKY_MACRO_ARGUMENT:
{
struct functionlike_define_directive_argument *arg=va_arg(args,struct functionlike_define_directive_argument*);
case WONKY__CONVERSION_WONKY_TOKEN_LINE:
{
struct token *token=va_arg(args,struct token*);
+ wonky_fprintf(s,"%Wt",token);
size_t begining_of_real_line=token->delta->location->starting_byte_index;
size_t ending_of_real_line=token->delta->location->starting_byte_index;
for(begining_of_real_line ;begining_of_real_line && token->delta->location->src->src[begining_of_real_line]!='\n' ;--begining_of_real_line);
%WIC - inclusion chain (takes Token_Pointer )
%WPC - token pointer context call stack ( takes Token_Pointer *)
%WPc - token pointer context ( takes Token_Pointer_Context *)
+ %WPl - token pointer source line ( takes Token_Pointer * )
%WMA - macro argument
%WMf - functionlike macro
%Wtl - print line containing token ( takes token*)
*/
void wonky__parse_scan_format(const char *begining, struct wonky__scanformat *destination)
{
+ /*here be dragons ...*/
destination->forward_crawl=1;
destination->modifier=WONKY__MOD_END;
destination->conversion=WONKY__CONVERSION_END;
{
destination->conversion=WONKY__CONVERSION_WONKY_TOKEN_POINTER_CONTEXT;
++destination->forward_crawl;
+ } else if(destination->wonky_form && begining[destination->forward_crawl]=='l')
+ {
+ destination->conversion=WONKY__CONVERSION_WONKY_TOKEN_POINTER_LINE;
+ ++destination->forward_crawl;
}
break;
case 'M':
F diff --git a/src/misc/wonky_stream.h b/src/misc/wonky_stream.h --- a/src/misc/wonky_stream.h +++ b/src/misc/wonky_stream.h
int wonky_fprintf(struct wonky_stream *s,const char *format,...);
int wonky_vfprintf(struct wonky_stream *s,const char *format,va_list args);
+ int wonky_printf_underline(const char *format,...);
+ int wonky_vprintf_underline(const char *format,va_list args);
+ int wonky_fprintf_underline(struct wonky_stream *s,const char *format,...);
+ int wonky_vfprintf_underline(struct wonky_stream *s,const char *format,va_list args);
ssize_t wonky_stream_int_to_decimal(struct wonky_stream *s,intmax_t a);
ssize_t wonky_stream_uint_to_decimal(struct wonky_stream *s,uintmax_t a);
F diff --git a/src/misc/wonky_stream.hh b/src/misc/wonky_stream.hh --- a/src/misc/wonky_stream.hh +++ b/src/misc/wonky_stream.hh
WONKY__CONVERSION_WONKY_TOKEN_POINTER_CALL_STACK,
WONKY__CONVERSION_WONKY_MACRO_ARGUMENT,
WONKY__CONVERSION_WONKY_TOKEN_POINTER_CONTEXT,
+ WONKY__CONVERSION_WONKY_TOKEN_POINTER_LINE,
WONKY__CONVERSION_WONKY_FUNCTIONLIKE_MACRO,
WONKY__CONVERSION_WONKY_TOKEN_LINE,
WONKY__CONVERSION_WONKY_SOURCE_LOCATION,
F diff --git a/src/semantics/constraints/linkage_constraints.c b/src/semantics/constraints/linkage_constraints.c --- a/src/semantics/constraints/linkage_constraints.c +++ b/src/semantics/constraints/linkage_constraints.c
if(previous_denoted_with_same_id->denotation!=DT_Object)
{
- push_translation_error("redeclaration of %D",translation_data,denoted_object);
- push_translation_note("previously declared as %D",translation_data,previous_denoted_with_same_id);
+ push_translation_error("redeclaration of %Wd",translation_data,denoted_object);
+ push_translation_note("previously declared as %Wd",translation_data,previous_denoted_with_same_id);
return 0;
}
F diff --git a/src/semantics/identifiers/linkage.c b/src/semantics/identifiers/linkage.c --- a/src/semantics/identifiers/linkage.c +++ b/src/semantics/identifiers/linkage.c
denoted_function->linkage=( (hold_function->linkage==LINKAGE_NONE) ? LINKAGE_EXTERNAL : hold_function->linkage);
}else
{
- push_translation_error("mismtatching types for %t",translation_data,denoted_function->id);
- push_translation_note("first it was declared with type %T",translation_data,hold_function->type);
- push_translation_note("now it's declared with type %T",translation_data,denoted_function->type);
+ push_translation_error("mismtatching types for %WI",translation_data,denoted_function->id);
+ push_translation_note("first it was declared with type %WT",translation_data,hold_function->type);
+ push_translation_note("now it's declared with type %WT",translation_data,denoted_function->type);
return;
}
}else
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
if(token_ptr_has_buffered_tokens(token_pointer))
return token_ptr_get_buffered_token(token_pointer);
- token_ptr_goto_next_normal_token(token_pointer);
+ token_ptr_goto_next_normal_token(token_pointer,1);
if(!token_ptr_has_remaining_tokens(token_pointer))
return get_eof_token();
token_ptr_goto_next_token(token_pointer);
+ wonky_printf("YYY token_ptr_get_token_under_pointer_inner\n");
token_ptr_assume_location_of_token(token_pointer,hold_token);
return hold_token;
}
- void token_ptr_goto_next_normal_token(struct Token_Pointer *token_pointer)
+ void token_ptr_goto_next_normal_token(struct Token_Pointer *token_pointer,_Bool assume_location)
{
struct token *hold_token;
if(token_ptr_has_buffered_tokens(token_pointer))
hold_token=(struct token*)token_pointer->context->current_token_node->data;
wonky_assert(hold_token!=NULL);
- token_ptr_assume_location_of_token(token_pointer,hold_token);
+
+ if(assume_location)
+ {
+ wonky_printf("YYY token_ptr_goto_next_normal_token\n");
+ token_ptr_assume_location_of_token(token_pointer,hold_token);
+ }
if(!token_ptr_do_preprocessing_stuff(token_pointer,hold_token))
return;
{
struct token *ret;
- token_ptr_goto_next_normal_token(token_pointer);
+ token_ptr_goto_next_normal_token(token_pointer,0);
if(token_ptr_has_buffered_tokens(token_pointer))
return token_ptr_check_buffered_token(token_pointer);
void token_ptr_assume_location_of_token(struct Token_Pointer *ptr,struct token *token)
{
wonky_assert(token!=NULL);
+ wonky_printf("XXX token_ptr_assume_location_of_token %Wt %WPc\n",token,ptr->context);
ptr->context->line+=token->delta->line_offset;
ptr->context->column=token->delta->column;
}
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 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_goto_next_token(struct Token_Pointer *token_pointer);
- void token_ptr_goto_next_normal_token(struct Token_Pointer *token_pointer);
+ void token_ptr_goto_next_normal_token(struct Token_Pointer *token_pointer,_Bool assume_location);
struct Token_Pointer* get_token_ptr(struct Preprocessing_Translation_Unit *unit,struct Program *program);
void delete_token_ptr(struct Token_Pointer *ptr);