WONKY



LOG | FILES | OVERVIEW


F diff --git a/src/backend/text/print/print.c b/src/backend/text/print/print.c --- a/src/backend/text/print/print.c +++ b/src/backend/text/print/print.c
do
{
- name=get_source_name(*base_source_names,this_directory[0]);
+ name=get_source_name(*base_source_names,program);
if(name==NULL)
{
F diff --git a/src/debug/debug_lexer.h b/src/debug/debug_lexer.h --- a/src/debug/debug_lexer.h +++ b/src/debug/debug_lexer.h
_Bool is_valid_keyword_enum(enum LEXER_TYPE keyword);
_Bool is_valid_token(struct token *token);
+ _Bool is_valid_automata_node(struct Automata_Node *node);
#endif
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
/*
%T - type
%D - denoted
- %t - token
+ %I - identifier
*/
- struct Translation_Message* get_translation_message(const char *message_format,struct Translation_Data *translation_data,char *filename,size_t line,size_t column,va_list args)
+ struct Translation_Message* get_translation_message(const char *message_format,struct Program *program,struct Source_Location *location,va_list args)
{
size_t i;
struct Translation_Message *ret;
- hold_return_string=get_translation_message_location_prefix(filename,line,column);
+ hold_return_string=get_translation_message_location_prefix(location->src_name->normalised_name,location->line,location->column);
for(i=0;i<1000 && message_format[i]!='\0';++i)
{
switch(message_format[i+1])
{
- case 't':
- hold_return_substring=get_string_for_token_error(va_arg(args,struct token*),translation_data);
+ case 'I':
+ hold_return_substring=get_string_for_id_error(va_arg(args,struct identifier*));
break;
case 'T':
- hold_return_substring=get_string_for_type_error(va_arg(args,struct Type*),translation_data);
+ hold_return_substring=get_string_for_type_error(va_arg(args,struct Type*));
break;
case 'D':
- hold_return_substring=get_string_for_denoted_error(va_arg(args,struct Denoted*),translation_data);
+ hold_return_substring=get_string_for_denoted_error(va_arg(args,struct Denoted*));
break;
default:
continue; /*goes to top for loop*/
ret=wonky_malloc(sizeof(struct Translation_Message));
ret->message=hold_return_string;
- ret->line=line;
- ret->column=column;
- ret->filename=filename;
+ ret->line=location->line;
+ ret->column=location->column;
+ ret->filename=location->src_name->normalised_name;
return ret;
}
- void push_translation_message_inner(const char *prefix,const char *message_format,struct Translation_Data *translation_data,va_list args)
+ void push_translation_message_inner(const char *prefix,const char *message_format,struct Program *program,struct Source_Location *location,va_list args)
{
struct Translation_Message *hold_message;
char *filename=NULL;
size_t line=0;
size_t row=0;
- if(translation_data->tokens->size>0)
- {
- struct token *hold_token;
- hold_token=translation_data->tokens->first->data;
- filename=(char*)hold_token->filename;
- line=hold_token->line;
- row=hold_token->column;
- }
- hold_message=get_translation_message(message_format,translation_data,filename,line,row,args);
+ hold_message=get_translation_message(message_format,program,location,args);
hold_message->message=gstr_append_and_consume(gstr_to_heap(prefix),hold_message->message);
- Queue_Push(translation_data->errors,hold_message);
+ Queue_Push(program->errors,hold_message);
}
void push_translation_error(const char *message_format,struct Translation_Data *translation_data, ...)
{
va_list args;
va_start(args,translation_data);
- push_translation_message_inner("[Error] ",message_format,translation_data,args);
+ push_translation_message_inner("[Error] ",message_format,translation_data->program,translation_data->token_pointer->current_location,args);
va_end(args);
}
void push_translation_note(const char *note_message,struct Translation_Data *translation_data, ...)
{
va_list args;
va_start(args,translation_data);
- push_translation_message_inner("[Note] ",note_message,translation_data,args);
+ push_translation_message_inner("[Note] ",note_message,translation_data->program,translation_data->token_pointer->current_location,args);
va_end(args);
}
void push_lexing_error(char *error_message,struct Lexer_Data *lexer_data)
{
Queue_Push(compile_data->errors,gstr_to_heap(message));
}
- char* get_string_for_type_error(struct Type *type,struct Translation_Data *translation_data)
+ char* get_string_for_type_error(struct Type *type)
{
char *ret;
struct Type *current;
ret=gstr_append_and_consume(gstr_to_heap("struct "),ret);
hack2:
{
- struct token *id;
+ struct identifier *id;
id=((struct Type_Struct_Union*)current)->struct_union->id;
- ret=gstr_append_and_consume(ret,gstr_dup(id->data,id->data+id->data_size,id->data_size+1));
+ ret=gstr_append_and_consume(ret,gstr_dup(id->data,id->data+id->size,id->size+1));
}
break;
default:
}
return ret;
}
- char* get_string_for_denoted_error(struct Denoted *denoted,struct Translation_Data *translation_data)
+ char* get_string_for_denoted_error(struct Denoted *denoted)
{
char *ret;
return ret;
}
- char* get_string_for_token_error(struct token *token,struct Translation_Data *translation_data)
+ char* get_string_for_id_error(struct identifier *id)
{
char *ret;
- ret=gstr_dup(token->data,token->data+token->data_size,token->data_size+1);
+ ret=gstr_dup(id->data,id->data+id->size,id->size+1);
return ret;
}
F diff --git a/src/environment/error/gcc_error.h b/src/environment/error/gcc_error.h --- a/src/environment/error/gcc_error.h +++ b/src/environment/error/gcc_error.h
/*
%T print type - takes pointer to Type
%D denoted - takes pointer to Denoted
- %t token - takes pointer to a token
+ %I identifier - takes pointer to an id
*/
struct Translation_Message* get_translation_message(const char *message_format,struct Program *program,struct Source_Location *location,va_list args);
struct Translation_Message* get_translation_message_inner(const char *message,struct Program *program,struct Source_Location *location);
- void push_translation_message_inner(const char *prefix,const char *message_format,struct Translation_Data *translation_data,va_list args);
+ void push_translation_message_inner(const char *prefix,const char *message_format,struct Program *program,struct Source_Location *location,va_list args);
void push_translation_error(const char *message_format,struct Translation_Data *translation_data, ...);
void push_translation_note(const char *note_message,struct Translation_Data *translation_data, ...);
void push_compile_error(const char *message,struct Compile_Data *compile_data);
void push_compile_note(const char *message,struct Compile_Data *compile_data);
- char* get_string_for_type_error(struct Type *type,struct Translation_Data *translation_data);
- char* get_string_for_denoted_error(struct Denoted *denoted,struct Translation_Data *translation_data);
- char* get_string_for_token_error(struct token *token,struct Translation_Data *translation_data);
+ char* get_string_for_type_error(struct Type *type);
+ char* get_string_for_denoted_error(struct Denoted *denoted);
+ char* get_string_for_id_error(struct identifier *id);
char* get_translation_message_location_prefix(char *filename,size_t line,size_t column);
void print_translation_error(FILE *out,struct Translation_Message *message);
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
struct token* preprocessing_lex_directive(struct Lexer_Data *lexer_data,struct Source_Location *where)
{
- return get_error_token();
+ return get_error_token("PREPROCESSING DIRECTIVES NOT DONE",where,lexer_data->program);
}
#endif
F diff --git a/src/frontend/lex/lex_preprocessing_directive.h b/src/frontend/lex/lex_preprocessing_directive.h --- a/src/frontend/lex/lex_preprocessing_directive.h +++ b/src/frontend/lex/lex_preprocessing_directive.h
#include <token.h>
#include <lexer.h>
+ #include <source_file.h>
+
struct token* preprocessing_lex_directive(struct Lexer_Data *lexer_data,struct Source_Location *where);
F diff --git a/src/frontend/lex/lexer.c b/src/frontend/lex/lexer.c --- a/src/frontend/lex/lexer.c +++ b/src/frontend/lex/lexer.c
Map_Push(
program->preprocessing_translation_units,
- src_name->normalised_source_name,
+ src_name->normalised_name,
src_name->normalised_name_size,
lexed_unit
);
ret->where_in_src=0;
ret->which_column=0;
ret->which_row=0;
- ret->token_size=0;
- ret->best_token_size=0;
- ret->best_token_line=0;
- ret->best_token_column=0;
- ret->best_token_where_in_src_start=0;
- ret->best_token_where_in_src_end=0;
- ret->best_token_beg_line=0;
ret->is_in_the_begining_of_line=0;
- ret->src=get_source_file(src_name);
+ ret->automata_view=AUTOMATA_VIEW_NORMAL;
+ ret->src=get_source_file(src_name,program);
ret->program=program;
return ret;
{
switch(lexer_data->src->src[lexer_data->where_in_src])
{
- '\n':
+ case '\n':
state=BLANK_SPACE;
++lexer_data->where_in_src;
lexer_data->is_in_the_begining_of_line=1;
break;
- ' ':
- '\t':
- '\v':
+ case ' ':
+ case '\t':
+ case '\v':
if(state==POSSIBLE_LINE_SPLICE)
state=NON_WHITE_SPACE;
else
++lexer_data->where_in_src;
break;
- '\\':
+ case '\\':
if(state==POSSIBLE_LINE_SPLICE)
{
state=NON_WHITE_SPACE;
if(lexer_eof(lexer_data))
return get_eof_token();
else
- return lexer_get_general_error(lexer_data);
-
+ return get_error_token("Unrecognised lexical element",get_source_location(
+ lexer_data->which_column,
+ lexer_data->which_row,
+ lexer_data->where_in_src,
+ lexer_data->src->src_name
+ ),
+ lexer_data->program);
}while(hold_node->keyword!=KW_COMMENT);
ret=lexer_make_token_finishing_on_node(lexer_data, hold_node, where_does_the_token_start_in_the_source_file);
head=&chonky[0];
follower=NULL;
- while(hold_node!=NULL)
+ while(head!=NULL)
{
- follower=hold_node;
- hold_node=lexer_feed_automata_next_char(lexer_data,hold_node);
+ follower=head;
+ head=lexer_feed_automata_next_char(lexer_data,head);
}
return follower;
F diff --git a/src/frontend/lex/lexer.h b/src/frontend/lex/lexer.h --- a/src/frontend/lex/lexer.h +++ b/src/frontend/lex/lexer.h
#include <automata.h>
#include <token.h>
+ #include <translation_unit.h>
struct Lexer_Data
{
void lex(struct Source_Name *src_name,struct Program *program);
- struct Preprocessing_Translation_Unit* lex_inner_until(struct Lexer_Data *lexer_data);
+ struct Preprocessing_Translation_Unit* lex_inner(struct Lexer_Data *lexer_data);
struct Lexer_Data* get_lexer_data(struct Source_Name *src_name,struct Program *program);
void lexer_skip_white_space(struct Lexer_Data *lexer_data);
F diff --git a/src/frontend/lex/lexer.hh b/src/frontend/lex/lexer.hh --- a/src/frontend/lex/lexer.hh +++ b/src/frontend/lex/lexer.hh
struct define_directive;
struct Source_Name;
struct Source_File;
+ struct Lexer_Data;
enum Automata_View
{
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
{
enum LEXER_TYPE hold_kw;
struct Denotation_Prototype *ret;
- ret=(struct Denotation_Prototype*)get_denotation_prototype(translation_data->types);
+ ret=(struct Denotation_Prototype*)get_denotation_prototype(translation_data->program);
while(1)
{
chomp(translation_data);
if(check(translation_data,KW_ID,0))
{
- struct token *id;
+ struct identifier *id;
+ struct token_identifier *hold_token;
struct Denoted_Struct_Union *tag;
- id=Queue_Pop(translation_data->tokens);
+
+ hold_token=(struct token_identifier*)get_next_token(translation_data);
+
+ wonky_assert(hold_token->type=KW_ID);
+
+ id=hold_token->id;
+
tag=(struct Denoted_Struct_Union*)check_tag(scope,id);
if(tag==NULL)
ret->specifier=TS_ENUM;
if(check(translation_data,KW_ID,0))
{
- struct token *id;
+ struct identifier *id;
+ struct token_identifier *hold_token;
struct Denoted_Enum *enumerator;
- id=Queue_Pop(translation_data->tokens);
+
+ hold_token=(struct token_identifier*)get_next_token(translation_data);
+ wonky_assert(hold_token->type=KW_ID);
+
+ id=hold_token->id;
enumerator=(struct Denoted_Enum*)check_tag(scope,id);
if(enumerator==NULL)
{
if(ret->specifier==TS_NONE)
{
struct Denoted *hold;
- hold=check_ordinary(scope,(struct token*)translation_data->tokens->first->data);
+ struct token_identifier *hold_token;
+ struct identifier *id;
+
+ hold_token=(struct token_identifier*)get_next_token(translation_data);
+
+ wonky_assert(hold_token->type=KW_ID);
+
+ id=hold_token->id;
+
+ hold=check_ordinary(scope,id);
if(hold!=NULL && hold->denotation==DT_Typedef)
{
ret->type=((struct Denoted_Type*)hold)->type;
{
if(check(translation_data,KW_ID,0))
{
- base->id=Queue_Pop(translation_data->tokens);
+ struct token_identifier *hold_token;
+ struct identifier *id;
+
+ hold_token=(struct token_identifier*)get_next_token(translation_data);
+ wonky_assert(hold_token->type=KW_ID);
+ id=hold_token->id;
+
+ base->id=id;
parse_direct_declarator_finish(translation_data,scope,base);
}else if(get_and_check(translation_data,KW_OPEN_NORMAL))
while(!check(translation_data,KW_CLOSE_NORMAL,0))
{
- Queue_Push(hack,Queue_Pop(translation_data->tokens));
+ Queue_Push(hack,get_next_token(translation_data));
}
/*remove closing )*/
chomp(translation_data);
F diff --git a/src/frontend/parse/parse_declaration.h b/src/frontend/parse/parse_declaration.h --- a/src/frontend/parse/parse_declaration.h +++ b/src/frontend/parse/parse_declaration.h
#include <linkage.h>
#include <common.h>
#include <debug.h>
+ #include <gcc_error.h>
F diff --git a/src/semantics/identifiers/denoted.c b/src/semantics/identifiers/denoted.c --- a/src/semantics/identifiers/denoted.c +++ b/src/semantics/identifiers/denoted.c
wonky_assert(is_valid_denoted_struct_union(ret));
return (struct Denoted*)ret;
}
- struct Denoted* get_denotation_prototype(struct Map *types)
+ struct Denoted* get_denotation_prototype(struct Program *program)
{
struct Denotation_Prototype *ret;
ret=wonky_malloc(sizeof(struct Denotation_Prototype));
ret->denotation=DT_Prototype;
ret->type=NULL;
- ret->node=types;
+ ret->node=program->types;
ret->storage_class=SCS_NONE;
ret->specifier=TS_NONE;
ret->constraint=TC_NONE;
F diff --git a/src/semantics/identifiers/denoted.h b/src/semantics/identifiers/denoted.h --- a/src/semantics/identifiers/denoted.h +++ b/src/semantics/identifiers/denoted.h
struct Denoted* extract_denoted(struct Denoted_Base *base,struct Denotation_Prototype *prototype,_Bool allow_abstract);
struct Denoted* get_denoted_statement(struct token *id,struct AST *statement,struct Denoted_Object *previous_denoted_object);
- struct Denoted* get_denotation_prototype(struct Map *types);
+ struct Denoted* get_denotation_prototype(struct Program *program);
void delete_denoted_wrapper(void *denoted);
F diff --git a/src/semantics/identifiers/scope.c b/src/semantics/identifiers/scope.c --- a/src/semantics/identifiers/scope.c +++ b/src/semantics/identifiers/scope.c
return hold;
}
- struct Denoted* check_tag(struct Scope *current,struct token *id)
+ struct Denoted* check_tag(struct Scope *current,struct identifier *id)
{
void *hold;
hold=NULL;
F diff --git a/src/semantics/identifiers/scope.h b/src/semantics/identifiers/scope.h --- a/src/semantics/identifiers/scope.h +++ b/src/semantics/identifiers/scope.h
#include <queue.h>
#include <constraints.h>
#include <common.h>
+ #include <identifier.h>
enum Scope_Type;
struct Scope* get_partial_normal_scope(struct Normal_Scope *scope);
struct Scope* get_function_scope(struct Scope *parent,struct Denoted_Function *function);
- struct Denoted_Statement* check_label(struct Scope *current,struct token *id);
- struct Denoted* check_tag(struct Scope *current,struct token *id);
- void* check_ordinary(struct Scope *current,struct token *id);
- void* check_struct_union_member(struct Normal_Scope *inner,struct token *id);
+ struct Denoted_Statement* check_label(struct Scope *current,struct identifier *id);
+ struct Denoted* check_tag(struct Scope *current,struct identifier *id);
+ void* check_ordinary(struct Scope *current,struct identifier *id);
+ void* check_struct_union_member(struct Normal_Scope *inner,struct identifier *id);
/*
F diff --git a/src/semantics/program/program.h b/src/semantics/program/program.h --- a/src/semantics/program/program.h +++ b/src/semantics/program/program.h
char get_and_check_unsafe(struct Translation_Data *translation_data,enum LEXER_TYPE kw);
void chomp(struct Translation_Data *translation_data);
enum LEXER_TYPE kw_get(struct Translation_Data *translation_data);
+ struct token* get_next_token(struct Translation_Data *translation_data);
void flush_tokens(struct Queue *tokens);
F diff --git a/src/semantics/value/constant.h b/src/semantics/value/constant.h --- a/src/semantics/value/constant.h +++ b/src/semantics/value/constant.h
#include <type.h>
#include <common.h>
#include <automata.h>
+ #include <ast.h>
struct Constant
{
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
struct Type* get_type_error(struct Type *type,struct Translation_Data *translation_data);
struct Type* get_struct_union_type(struct Denotation_Prototype *prototype,struct Translation_Data *translation_data);
- struct Struct_Union* get_struct_union_base(struct Scope *scope ,enum Type_Specifier struct_or_union,struct token *id);
- struct Enum *get_enum_base(struct token *id);
+ struct Struct_Union* get_struct_union_base(struct Scope *scope ,enum Type_Specifier struct_or_union,struct identifier *id);
+ struct Enum *get_enum_base(struct identifier *id);
struct Type* get_basic_type(struct Denotation_Prototype *prototype,struct Translation_Data *translation_data);
struct Type* get_pointer_type(struct Type *points_to,_Bool is_const,_Bool is_volatile,struct Translation_Data *translation_data);
struct Type* get_array_type(struct Type *array_of,struct AST* number_of_elements,struct Translation_Data *translation_data);
struct Type* get_enum_type(struct Denotation_Prototype *prototype,struct Translation_Data *translation_data);
struct Type* get_function_type(struct Type *return_type,struct Queue *parameters,struct Normal_Scope* function_prototype_scope,_Bool is_variadic,struct Translation_Data *translation_data);
+ /*returns 0 if the rebasing of the type makes no sense*/
+ _Bool rebase_type(struct Type *rebase,struct Type *onto);
struct Type_Basic* get_type_insecure(enum Type_Specifier type_specifier,enum Type_Signedness sign,enum Type_Constraint constraint,size_t type_size,struct Translation_Data *translation_data);
struct Type* get_type_for_promotion(struct Type *type,struct Translation_Data *translation_data);
_Bool type_is_a_variable_length_array(struct Type *type);
_Bool type_is_an_array(struct Type *type);
- /*these return 0 if constant/volatile-ness make no sense for the type*/
+ /*these return 0 if constant/volatile-ness makes no sense for the type*/
_Bool type_is_constant(struct Type *type);
_Bool type_is_volatile(struct Type *type);
- /*these return 0 if constant/volatile-ness make no sense for the type*/
+ /*these return 0 if constant/volatile-ness makes no sense for the type*/
_Bool type_is_constant(struct Type *type);
_Bool type_is_volatile(struct Type *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
}
}
/*where_to_search ends in a NULL pointer*/
- struct Source_File* get_source_file(char *filename,char **where_to_search)
+ struct Source_File* get_source_file(struct Source_Name *name,struct Protram *program)
{
FILE *in;
char *temp_name;
F diff --git a/src/syntax/source_file.h b/src/syntax/source_file.h --- a/src/syntax/source_file.h +++ b/src/syntax/source_file.h
};
struct Source_File* extract_source_file(FILE *in,struct Source_Name *name);
- struct Source_File* get_source_file(char *filename,char **where_to_search);
- struct Source_Name* get_source_name(char *filename,char *base);
- struct Source_Location* get_source_location(size_t line,size_t column,size_t on_which_byte,struct Source_Location *src_name);
+ struct Source_File* get_source_file(struct Source_Name *name,struct Program *program);
+ struct Source_Name* get_source_name(char *filename,struct Program *program);
+ struct Source_Location* get_source_location(size_t line,size_t column,size_t on_which_byte,struct Source_Name *src_name);
void normalise_source_name(struct Source_Name *name);
char src_getc(struct Source_File *src,char skip_line_splice,char skip_comments,char skip_new_line);
void src_ungetc(struct Source_File *src);