F diff --git a/src/backend/asm/intel/intel_compile.c b/src/backend/asm/intel/intel_compile.c
--- a/src/backend/asm/intel/intel_compile.c
+++ b/src/backend/asm/intel/intel_compile.c
compile_ast_to_intel_asm(compile_data,(struct AST*)expression->left);
push_intel_asm_instruction(compile_data,intel_asm_get_pop(INTEL_ASM_REGISTER_RAX));
- push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(ax_register,ax_register,INTEL_ASM_OP_TEST));
+ push_intel_asm_instruction(compile_data,get_intel_asm_binary_instruction(intel_asm_get_ax_register(),intel_asm_get_ax_register(),INTEL_ASM_OP_TEST));
push_intel_asm_instruction(compile_data,get_intel_asm_jump_instruction(second,INTEL_ASM_OP_JZ));
compile_ast_to_intel_asm(compile_data,(struct AST*)expression->center);
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
args);
va_end(args);
}
- void push_token_ptr_error(const char *message_format,struct Token_Pointer *ptr,...)
+ void push_token_ptr_error(const char *message_format,struct Token_Pointer *ptr,...)
{
va_list args;
va_start(args,ptr);
ptr->context->column,
args);
va_end(args);
+ ptr->state=TOKEN_POINTER_STATE_ERROR;
}
char* get_string_for_type_error(struct Type *type)
{
F diff --git a/src/frontend/lex/lex_preprocessing_directive.c b/src/frontend/lex/lex_preprocessing_directive.c
--- a/src/frontend/lex/lex_preprocessing_directive.c
+++ b/src/frontend/lex/lex_preprocessing_directive.c
get_functionlike_define_directive_argument(directive));
((struct token_keyword*)hold_token)->id->hold_functionlike_define_directive=directive->define;
delete_token(hold_token);
- }else if(hold_token->type==KW_OPEN_NORMAL)
+ }else if(hold_token->type==KW_CLOSE_NORMAL)
{
delete_token(hold_token);
break;
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(ptr->context->current_token_node!=NULL)
{
push_token_ptr_error("Unexpected token at end of include directive",ptr);
- ptr->state=TOKEN_POINTER_STATE_ERROR;
return;
}
include_name=((struct token_string*)hold_token)->constant->value;
break;
default:
push_token_ptr_error("Unsupported symbol found inside filename in include directive with angular brackets and macro expansion",ptr);
- ptr->state=TOKEN_POINTER_STATE_ERROR;
return;/*NOTICE*/
}
hold_token=token_ptr_get_token_under_pointer(ptr);
if(ptr->context->current_token_node!=NULL)
{
push_token_ptr_error("Unexpected token at end of include directive",ptr);
- ptr->state=TOKEN_POINTER_STATE_ERROR;
return;
}
}else if(hold_token->type==KW_LESS_EQ)
{
push_token_ptr_error("'=' is not supported inside filename in include directive with angular brackets and macro expansion",ptr);
- ptr->state=TOKEN_POINTER_STATE_ERROR;
return;
}
}
void token_ptr_execute_functionlike_macro_argument(struct Token_Pointer *ptr,struct functionlike_define_directive_argument *argument)
{
+ token_ptr_goto_next_token(ptr);
if(argument->number_of_substitution_tokens==0)
token_ptr_goto_next_token(ptr);
else
struct token *hold_token;
struct Queue_Node *hold_argument_node;
struct Queue_Node *hold_leading_token_node;
+ struct functionlike_define_directive_argument *hold_arg;
+
- hold_argument_node=macro->arguments->first;
- hold_leading_token_node=token_ptr_get_token_under_pointer(ptr);
+ hold_token=token_ptr_get_token_under_pointer(ptr);
+ if(hold_token->type!=KW_OPEN_NORMAL)
+ {
+ push_token_ptr_error("Expected '(' after functionlike macro id",ptr);
+ return;
+ }
+ hold_argument_node=macro->arguments->first;
+ hold_leading_token_node=token_ptr_get_current_queue_node(ptr);
number_of_tokens_in_argument=0;
ptr->state=TOKEN_POINTER_STATE_DONT_EXPAND_MACROS;
- while(open_bracket_count>=1 && token_ptr_has_buffered_tokens(ptr))
+ while(open_bracket_count>=1 && token_ptr_has_remaining_tokens(ptr))
{
hold_token=token_ptr_get_token_under_pointer(ptr);
if(hold_token->type==KW_OPEN_NORMAL)
--open_bracket_count;
else if(hold_token->type==KW_COMMA && open_bracket_count==1) /*if we are at the top level ()*/
{
-
+ if(hold_argument_node==NULL)
+ {
+ push_token_ptr_error("Too many arguments given to functionlike macro",ptr);
+ return;
+ }
+ if(number_of_tokens_in_argument==0)
+ {
+ push_token_ptr_error("No tokens in functionlike macro",ptr);
+ return;
+ }
+ hold_arg=(struct functionlike_define_directive_argument*)hold_argument_node->data;
+ hold_arg->first_in_argument_substitution_tokens=hold_leading_token_node;
+ hold_arg->number_of_substitution_tokens=number_of_tokens_in_argument;
+
+ number_of_tokens_in_argument=0;
+ hold_argument_node=hold_argument_node->prev;
+ hold_leading_token_node=token_ptr_get_current_queue_node(ptr);
}else
{
++number_of_tokens_in_argument;
}
}
+
+ if(hold_argument_node==NULL || hold_argument_node->prev!=NULL)
+ {
+ push_token_ptr_error("Too few arguments given to functionlike macro",ptr);
+ return;
+ }
+ hold_arg=(struct functionlike_define_directive_argument*)hold_argument_node->data;
+ hold_arg->first_in_argument_substitution_tokens=hold_leading_token_node;
+ hold_arg->number_of_substitution_tokens=number_of_tokens_in_argument;
+
/*
* we assume that this was the state of the pointer before setting it
else
return NULL;
}
+ struct Queue_Node* token_ptr_get_current_queue_node(struct Token_Pointer *ptr)
+ {
+ return ptr->context->current_token_node;
+ }
struct token* token_ptr_check_buffered_token(struct Token_Pointer *ptr)
{
if(token_ptr_has_buffered_tokens(ptr))
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_buffered_token(struct Token_Pointer *ptr);
struct token* token_ptr_check_buffered_token(struct Token_Pointer *ptr);
+ struct Queue_Node* token_ptr_get_current_queue_node(struct Token_Pointer *ptr);
+
void token_ptr_jump_to(struct Token_Pointer *ptr,struct Queue_Node *where_to,size_t number_of_remaining_tokens);
void token_ptr_jump_to_first(struct Token_Pointer *ptr,struct Queue *queue);
void delete_token_ptr_context(struct Token_Pointer_Context *context);