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
prototype=parse_declaration_specifiers(translation_data,scope);
- while(!get_and_check(translation_data,KW_SEMICOLON))
+ while(!translation_eof(translation_data) && !get_and_check(translation_data,KW_SEMICOLON))
{
hold=parse_declarator(translation_data,scope,prototype);
if(has_new_errors(translation_data))
{
chase_next_semicolon(translation_data);
- }
- else if(hold->denotation==DT_Function)
+ continue;
+ }else if(hold->denotation==DT_Function)
{
//Scope_Push(scope,hold,translation_data);
/*check if this is a function definition*/
struct Denoted_Base *base;
struct Denoted *hold;
_Bool is_variadic=0;
+ enum {
+ I_DONT_KNOW,
+ ABSTRACT,
+ NOT_ABSTRACT
+ } is_it_abstract_state=I_DONT_KNOW;
do
{
parse_declarator_inner(translation_data,(struct Scope*)function_prototype_scope,base);
- if(base->denotation!=DT_Object)
+ if(is_it_abstract_state==I_DONT_KNOW && base->denotation!=DT_Object && base->denotation!=DT_Prototype)
{
/*TODO error*/
- push_generic_error(translation_data->program,"expected object declaration in function prototype");
- // delete_denoted(hold);
+ push_translation_error("expected object declaration in function prototype",translation_data);
+ // delete_denoted(hold); ;-)
delete_denoted_prototype(prototype);
delete_denoted_base(base);
return 0;
+ }else if((is_it_abstract_state==ABSTRACT && base->id != NULL)
+ || (is_it_abstract_state==NOT_ABSTRACT && base->id == NULL))
+ {
+ push_translation_error("can't mix abstract and non-abstract declarations in function declaration",translation_data);
+ delete_denoted_prototype(prototype);
+ delete_denoted_base(base);
}
+ //#error handle a(int,int b), a(int,int)... a(int a,int b)... a(int,int) { ... }
+
hold=extract_denoted(base,prototype,1);
+ if(is_it_abstract_state==I_DONT_KNOW && base->id!=NULL)
+ is_it_abstract_state=NOT_ABSTRACT;
+ else if(is_it_abstract_state==I_DONT_KNOW && base->id==NULL)
+ is_it_abstract_state=ABSTRACT;
+
if(((struct Denoted_Object*)hold)->id!=NULL)
Scope_Push((struct Scope*)function_prototype_scope,hold,translation_data);
Queue_Push(parameters,((struct Denoted_Object*)hold));
F diff --git a/src/misc/print.c b/src/misc/print.c --- a/src/misc/print.c +++ b/src/misc/print.c
wonky_fprintf(out,"label");
return;
case DT_Object:
- switch(((struct Denoted_Object*)denoted)->linkage)
{
- case LINKAGE_INTERNAL:
- wonky_fprintf(out,"internally linked ");
- break;
- case LINKAGE_EXTERNAL:
- wonky_fprintf(out,"externally linked ");
- break;
- case LINKAGE_NONE:
- break;
- default:
- wonky_assert(SHOULD_NOT_REACH_HERE);
+ struct Denoted_Object *dobj=denoted;
+ switch(dobj->linkage)
+ {
+ case LINKAGE_INTERNAL:
+ wonky_fprintf(out,"internally linked ");
+ break;
+ case LINKAGE_EXTERNAL:
+ wonky_fprintf(out,"externally linked ");
+ break;
+ case LINKAGE_NONE:
+ break;
+ default:
+ wonky_assert(SHOULD_NOT_REACH_HERE);
+ }
+ if(dobj->id)
+ wonky_fprintf(out,"denoted object %WI%Wo is a %WT",dobj->id,
+ dobj->object,
+ dobj->object->type
+ );
+ else
+ wonky_fprintf(out,"denoted object %Wo that is %WT",dobj->object,
+ dobj->object->type
+ );
}
- wonky_fprintf(out,"denoted object %WI%Wo is a %WT",((struct Denoted_Object*)denoted)->id,
- ((struct Denoted_Object*)denoted)->object,
- ((struct Denoted_Object*)denoted)->object->type
- );
return;
case DT_Typedef:
wonky_fprintf(out,"typedef %WI to %WT",((struct Denoted_Type*)denoted)->id,((struct Denoted_Type*)denoted)->type);
switch(((struct Denoted_Function*)denoted)->linkage)
{
case LINKAGE_INTERNAL:
- wonky_fprintf(out,"an internally linked");
+ wonky_fprintf(out,"an internally linked ");
break;
case LINKAGE_EXTERNAL:
- wonky_fprintf(out,"an externally linked");
+ wonky_fprintf(out,"an externally linked ");
break;
case LINKAGE_NONE:
break;
case PKW_NOTYPE:
wonky_fprintf(out,"PKW_NOTYPE");
break;
+ case LT_EOF:
+ wonky_fprintf(out,"LT_EOF");
+ break;
+ case LT_ERROR:
+ wonky_fprintf(out,"LT_ERROR");
+ break;
default:
wonky_fprintf(out,"KW_ERROR");
}
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
{
struct Token_Pointer *tp=va_arg(args,struct Token_Pointer*);
struct Token_Pointer_Context *hold;
+ struct Token_Pointer_Context *hold_upper;
_Bool print_line=0;
wonky_assert(tp!=NULL);
if(tp->call_stack->size>2)
{
hold=(struct Token_Pointer_Context*)it->data;
wonky_assert(hold);
- if(hold->is_file_inclusion)
+ if(hold->is_file_inclusion && it->next!=NULL)
{
+ hold_upper=(struct Token_Pointer_Context*)it->next->data;
+ wonky_assert(hold_upper);
if(print_line)
wonky_write(s,"\n",1);
wonky_write(s,"\tIncluded in ",sizeof("\tIncluded in ")-1);
- wonky_write(s,hold->filename,hold->filename_size);
- wonky_fprintf(s,":%zu",hold->line+1);
+ wonky_write(s,hold_upper->filename,hold_upper->filename_size);
+ wonky_fprintf(s,":%zu",hold_upper->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->location);
+ wonky_fprintf(s,"\tExpanded from %WI %WSl",
+ hold->executed_macro_id,
+ hold->executed_macro_id->last_defined_macro_with_this_id->location);
print_line=1;
}
print_raw_token_text(s,token);
}
break;
+ case WONKY__CONVERSION_WONKY_LEXER_TYPE:
+ {
+ enum LEXER_TYPE t = va_arg(args,enum LEXER_TYPE);
+ print_keyword_enum(s,t);
+ }
+ break;
}
}
%WMf - functionlike macro
%Wtl - print line containing token ( takes token*)
%Wtr - print raw token text ( takes token *)
+ %WL - print lexer type ( takes enum LEXER_TYPE )
*/
void wonky__parse_scan_format(const char *begining, struct wonky__scanformat *destination)
{
break;
case 'L':
++destination->forward_crawl;
- destination->modifier=WONKY__MOD_LONG_DOUBLE;
+ if(destination->wonky_form)
+ {
+ destination->conversion=WONKY__CONVERSION_WONKY_LEXER_TYPE;
+ /*WARNING EARLY RETURN*/
+ return;
+ }else
+ {
+ destination->modifier=WONKY__MOD_LONG_DOUBLE;
+ }
break;
case 'j':
++destination->forward_crawl;
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_LINE,
WONKY__CONVERSION_WONKY_SOURCE_LOCATION,
WONKY__CONVERSION_WONKY_TOKEN_RAW_TEXT,
+ WONKY__CONVERSION_WONKY_LEXER_TYPE,
WONKY__CONVERSION_END
};
enum wonky__scanformat_modifier
F diff --git a/src/semantics/program/program.c b/src/semantics/program/program.c --- a/src/semantics/program/program.c +++ b/src/semantics/program/program.c
struct token *hold_token;
if(!token_ptr_has_remaining_tokens(translation_data->token_pointer))
{
- return LT_ERROR;
+ return LT_EOF;
}else
{
hold_token=token_ptr_check_next_normal_token(translation_data->token_pointer);
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 Token_Pointer *ret;
ret=wonky_malloc(sizeof(struct Token_Pointer));
- ret->context=get_token_ptr_context(unit->tokens->first,unit->tokens->size,1,0,0,0);
+ ret->context=get_token_ptr_context(unit->tokens->first,unit->tokens->size,0,0,0,0);
ret->call_stack=wonky_malloc(sizeof(struct Stack));
ret->state=TOKEN_POINTER_STATE_NORMAL;
ret->is_in_conditional_directive=0;
ret->saved_macro=NULL;
ret->is_file_inclusion=is_file_inclusion;
+
return ret;
}
void token_ptr_pop_context(struct Token_Pointer *ptr)