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
push_translation_error("expected ':' here",translation_data);
hold_right_expression=(struct AST_Expression*)get_error_tree(NULL);
}
- return (struct AST_Expression*)get_conditional_expression_tree(hold_right_expression,hold_center_expression,hold_right_expression,translation_data);
+ return (struct AST_Expression*)get_conditional_expression_tree(hold_left_expression,hold_center_expression,hold_right_expression,translation_data);
}else
{
return hold_left_expression;
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
}
}
break;
+ case WONKY__CONVERSION_POINTER:
case WONKY__CONVERSION_INT_HEXADECIMAL:
{
switch(fmt->modifier)
wonky_assert(tp!=NULL);
for(struct Stack_Node *it=tp->call_stack->first;it;it=it->next)
{
- wonky_assert(hold);
hold=(struct Token_Pointer_Context*)it->data;
+ wonky_assert(hold);
if(hold->is_file_inclusion)
{
if(print_line)
}
break;
+ case WONKY__CONVERSION_WONKY_TOKEN_POINTER_CALL_STACK:
+ {
+ struct Token_Pointer *tp=va_arg(args,struct Token_Pointer*);
+ _Bool print_line=0;
+ wonky_assert(tp);
+ wonky_fprintf(s,"%WPc\n",tp->context);
+ for(struct Stack_Node *it=tp->call_stack->first;it;it=it->next)
+ wonky_fprintf(s,"%WPc\n",it->data);
+
+
+ }
+ break;
+ case WONKY__CONVERSION_WONKY_TOKEN_POINTER_CONTEXT:
+ {
+ struct Token_Pointer_Context *hold=va_arg(args,struct Token_Pointer_Context*);
+ wonky_assert(hold);
+ wonky_fprintf(s,"ctx=%p : {\n\tcurrent_token_node = %p\n\tnum_remain_toks = %zu\n\tline = %zu\n\tcolumn = %zu\n\tbarier=%d\n\tfilename = \"",hold,hold->current_token_node,hold->number_of_remaining_tokens,hold->line,hold->column,hold->barrier);
+ wonky_write(s,hold->filename,hold->filename_size);
+ wonky_write(s,"\"",sizeof("\"")-1);
+ if(hold->executed_macro_id)
+ {
+ wonky_write(s,"\n\tmacro_id = \"",sizeof(" macro_id = \"")-1);
+ wonky_write(s,hold->executed_macro_id->data,hold->executed_macro_id->size);
+ wonky_write(s,"\"",sizeof("\"")-1);
+ }
+ if(hold->has_saved_functionlike_macro_state)
+ {
+ wonky_write(s,"\n\tmacro_state : \n\t{",sizeof("\n\tmacro_state : \n\t{")-1);
+ for(struct Queue_Node *it=hold->functionlike_macro_arguments_save_state->first;it;it=it->prev)
+ wonky_fprintf(s,"\n\t\t%WMA",it->data);
+ wonky_write(s,"\n\t}",sizeof("\n\t}")-1);
+ }
+ wonky_write(s,"\n}\n",sizeof("\n}\n")-1);
+
+ }
+ break;
+ case WONKY__CONVERSION_WONKY_MACRO_ARGUMENT:
+ {
+ struct functionlike_define_directive_argument *arg=va_arg(args,struct functionlike_define_directive_argument*);
+ wonky_fprintf(s,"first_in_argument_substitution_tokens=%p number_of_substitution_tokens=%zu",arg->first_in_argument_substitution_tokens,arg->number_of_substitution_tokens);
+ }
+ break;
+ case WONKY__CONVERSION_WONKY_FUNCTIONLIKE_MACRO:
+ {
+ struct functionlike_define_directive *arg=va_arg(args,struct functionlike_define_directive*);
+ wonky_assert(arg);
+ wonky_fprintf(s,"\n\"%WI\" : {\n\tis_variadic=%d",arg->id,(int)arg->is_variadic);
+ for(struct Queue_Node *it=arg->arguments->first;it;it=it->prev)
+ wonky_fprintf(s,"\n\t%WMA",it->data);
+ wonky_fprintf(s,"\n}\n");
+ }
+ break;
}
}
%Wo - object
%WC - constant
%WS - source name
- %WIC - inclusion chain ( Token_Pointer )
+ %WIC - inclusion chain (takes Token_Pointer )
+ %WPC - token pointer context call stack ( takes Token_Pointer *)
+ %WPc - token pointer context ( takes Token_Pointer_Context *)
+ %WMA - macro argument
+ %WMf - functionlike macro
*/
void wonky__parse_scan_format(const char *begining, struct wonky__scanformat *destination)
{
if(destination->wonky_form)
destination->conversion=WONKY__CONVERSION_WONKY_SOURCE_NAME;
break;
+ case 'P':
+ ++destination->forward_crawl;
+ if(destination->wonky_form && begining[destination->forward_crawl]=='C')
+ {
+ destination->conversion=WONKY__CONVERSION_WONKY_TOKEN_POINTER_CALL_STACK;
+ ++destination->forward_crawl;
+ } else if(destination->wonky_form && begining[destination->forward_crawl]=='c')
+ {
+ destination->conversion=WONKY__CONVERSION_WONKY_TOKEN_POINTER_CONTEXT;
+ ++destination->forward_crawl;
+ }
+ break;
+ case 'M':
+ ++destination->forward_crawl;
+ if(destination->wonky_form && begining[destination->forward_crawl]=='A')
+ {
+ destination->conversion=WONKY__CONVERSION_WONKY_MACRO_ARGUMENT;
+ ++destination->forward_crawl;
+ } else if(destination->wonky_form && begining[destination->forward_crawl]=='f')
+ {
+ destination->conversion=WONKY__CONVERSION_WONKY_FUNCTIONLIKE_MACRO;
+ ++destination->forward_crawl;
+ }
+ break;
}
}
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_CONSTANT,
WONKY__CONVERSION_WONKY_SOURCE_NAME,
WONKY__CONVERSION_WONKY_INCLUSION_CHAIN,
+ WONKY__CONVERSION_WONKY_TOKEN_POINTER_CALL_STACK,
+ WONKY__CONVERSION_WONKY_MACRO_ARGUMENT,
+ WONKY__CONVERSION_WONKY_TOKEN_POINTER_CONTEXT,
+ WONKY__CONVERSION_WONKY_FUNCTIONLIKE_MACRO,
WONKY__CONVERSION_END
};
enum wonky__scanformat_modifier
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
struct functionlike_define_directive_argument *hold;
struct Queue_Node *it;
+ wonky_assert(ctx->has_saved_functionlike_macro_state==0);
+
save=wonky_malloc(sizeof(struct Queue));
Queue_Init(save);
{
struct Queue_Node *it1,*it2;
struct functionlike_define_directive *macro=ctx->saved_macro;
-
+
for(it1=ctx->functionlike_macro_arguments_save_state->first,it2=macro->arguments->first;it1&&it2;it1=it1->prev,it2=it2->prev)
{
- *(struct functionlike_define_directive_argument*)it1->data=*(struct functionlike_define_directive_argument*)it2->data;
+ *(struct functionlike_define_directive_argument*)it2->data=*(struct functionlike_define_directive_argument*)it1->data;
wonky_free(it2->data);
}
Queue_Destroy(ctx->functionlike_macro_arguments_save_state);
+ wonky_free(ctx->functionlike_macro_arguments_save_state);
ctx->has_saved_functionlike_macro_state=0;
ctx->functionlike_macro_arguments_save_state=NULL;
in the macro argument were expanded. reseting to 1
*/
if(ptr->context->has_saved_functionlike_macro_state)
+ {
token_ptr_load_functionlike_macro_state_from_context(ptr->context);
+ }
delete_token_ptr_context(ptr->context);
ptr->context=Stack_Pop(ptr->call_stack);
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
points to the macro id if this context is the replacement tokens
are what this context is iterating over.
NULL otherwise
+ NOTE: very english
*/
struct identifier *executed_macro_id;
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
ret=wonky_malloc(sizeof(struct token_error));
ret->type=LT_ERROR;
ret->delta=get_source_location_delta(previous_location,current_location);
- ret->error=get_wonky_message(WONKY_MESSAGE_TYPE_ERROR,WONKY_MESSAGE_SOURCE_PREPROCESSING,current_location,"%s:%zu:%zu %s",current_location->src->src_name->name,current_location->line,current_location->column,hold_err.cs);
+ ret->error=get_wonky_message(WONKY_MESSAGE_TYPE_ERROR,WONKY_MESSAGE_SOURCE_PREPROCESSING,current_location->line,current_location->column,current_location->src->src_name->name,current_location->src->src_name->name_size,"%s:%zu:%zu %s",hold_err.cs);
return (struct token*)ret;
}
F diff --git a/tools/wsh b/tools/wsh
--- a/tools/wsh
+++ b/tools/wsh
#!/bin/sh
./wonky $1 > a.asm
- nasm a.asm -f elf64 -o a.o
+ nasm -O0 a.asm -f elf64 -o a.o
ld -m elf_x86_64 -L/lib/ -L/usr/lib/ -I /lib64/ld-linux-x86-64.so.2 /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o -lc /usr/lib/x86_64-linux-gnu/crtn.o a.o -o a
rm a.o