WONKY



LOG | FILES | OVERVIEW


F diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt
src/semantics/constraints/expression_constraints.c
src/semantics/constraints/linkage_constraints.c
src/semantics/constraints/statement_constraints.c
+ src/semantics/constraints/initialiser_constraints.c
src/semantics/identifiers/denoted.c
src/semantics/identifiers/linkage.c
src/semantics/identifiers/scope.c
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
}
}while(get_and_check(translation_data,KW_COMMA));
- return get_compound_initialiser((struct Type*)type_of_initialised,components,translation_data);
+ if(get_and_check(translation_data,KW_CLOSE_CURLY))
+ return get_compound_initialiser((struct Type*)type_of_initialised,components,translation_data);
+ else
+ return get_initialiser_error(get_compound_initialiser((struct Type*)type_of_initialised,components,translation_data));
}
/*
}
}while(get_and_check(translation_data,KW_COMMA));
- return get_compound_initialiser((struct Type*)type_of_initialised,components,translation_data);
+ if(get_and_check(translation_data,KW_CLOSE_CURLY))
+ return get_compound_initialiser((struct Type*)type_of_initialised,components,translation_data);
+ else
+ return get_initialiser_error(get_compound_initialiser((struct Type*)type_of_initialised,components,translation_data));
}
/*
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
struct Type *cast_type;
struct AST_Expression *operand;
+ chomp(translation_data);
cast_type=parse_type_name(translation_data,scope);
if(get_and_check(translation_data,KW_CLOSE_NORMAL))
{
F diff --git a/src/semantics/constraints/constraints.h b/src/semantics/constraints/constraints.h --- a/src/semantics/constraints/constraints.h +++ b/src/semantics/constraints/constraints.h
#include <expression_constraints.h>
#include <statement_constraints.h>
#include <linkage_constraints.h>
+ #include <initialiser_constraints.h>
#endif
F diff --git a/src/semantics/constraints/initialiser_constraints.c b/src/semantics/constraints/initialiser_constraints.c new file mode 100644 --- /dev/null +++ b/src/semantics/constraints/initialiser_constraints.c
+ #ifndef WONKY_INITIALISER_CONSTRAINTS_C
+ #define WONKY_INITIALISER_CONSTRAINTS_C WONKY_INITIALISER_CONSTRAINTS_C
+ #include <initialiser_constraints.h>
+
+ _Bool constraint_check_denoted_initialiser(struct Denoted_Object *to_be_initialised,struct Initialiser *initialiser,struct Translation_Data *translation_data)
+ {
+ return 1;
+ }
+ _Bool constraint_check_indexed_initialiser_by_ast(struct Type *element_type,struct AST_Expression *index,struct Initialiser *initialiser,struct Translation_Data *translation_data)
+ {
+ return 1;
+ }
+ _Bool constraint_check_indexed_initialiser_by_index(struct Type *element_type,size_t index,struct Initialiser *initialiser,struct Translation_Data *translation_data)
+ {
+ return 1;
+ }
+ _Bool constraint_check_expression_initialiser(struct AST_Expression *expression,struct Type *type_of_initialised,struct Translation_Data *translation_data)
+ {
+ return 1;
+ }
+ _Bool constraint_check_compound_initialiser(struct Initialiser_Compound *compound_initialiser,struct Translation_Data *translation_data)
+ {
+ return 1;
+ }
+
+ #endif
F diff --git a/src/semantics/constraints/initialiser_constraints.h b/src/semantics/constraints/initialiser_constraints.h new file mode 100644 --- /dev/null +++ b/src/semantics/constraints/initialiser_constraints.h
+ #ifndef WONKY_INITIALISER_CONSTRAINTS_H
+ #define WONKY_INITIALISER_CONSTRAINTS_H WONKY_INITIALISER_CONSTRAINTS_H
+ #include <initialiser.h>
+
+ _Bool constraint_check_denoted_initialiser(struct Denoted_Object *to_be_initialised,struct Initialiser *initialiser,struct Translation_Data *translation_data);
+ _Bool constraint_check_indexed_initialiser_by_ast(struct Type *element_type,struct AST_Expression *index,struct Initialiser *initialiser,struct Translation_Data *translation_data);
+ _Bool constraint_check_indexed_initialiser_by_index(struct Type *element_type,size_t index,struct Initialiser *initialiser,struct Translation_Data *translation_data);
+ _Bool constraint_check_expression_initialiser(struct AST_Expression *expression,struct Type *type_of_initialised,struct Translation_Data *translation_data);
+ _Bool constraint_check_compound_initialiser(struct Initialiser_Compound *compound_initialiser,struct Translation_Data *translation_data);
+
+ #endif
F diff --git a/src/semantics/value/initialiser.c b/src/semantics/value/initialiser.c --- a/src/semantics/value/initialiser.c +++ b/src/semantics/value/initialiser.c
ret->to_be_initialised=to_be_initialised;
ret->initialiser=initialiser;
- return (struct Initialiser*)ret;
+ if(constraint_check_denoted_initialiser(to_be_initialised,initialiser,translation_data))
+ return (struct Initialiser*)ret;
+ else
+ return get_initialiser_error((struct Initialiser*)ret);
}
struct Initialiser* get_indexed_initialiser(struct Type *type,size_t index,struct Initialiser *initialiser,struct Translation_Data *translation_data)
{
ret->index=index;
ret->initialiser=initialiser;
- return (struct Initialiser*)ret;
+ if(constraint_check_indexed_initialiser_by_index(type,index,initialiser,translation_data))
+ return (struct Initialiser*)ret;
+ else
+ return get_initialiser_error((struct Initialiser*)ret);
}
struct Initialiser* get_initialiser_expression(struct AST_Expression *expression,struct Type* type_of_initialised,struct Translation_Data *translation_data)
ret->kind=INITIALISER_EXPRESSION;
ret->expression=expression;
- return (struct Initialiser*)ret;
+ if(constraint_check_expression_initialiser(expression,type_of_initialised,translation_data))
+ return (struct Initialiser*)ret;
+ else
+ return get_initialiser_error((struct Initialiser*)ret);
}
struct Initialiser* get_compound_initialiser(struct Type *type,struct Queue *components,struct Translation_Data *translation_data)
{
free(components);/*BEWARE*/
- return (struct Initialiser*)ret;
+ if(constraint_check_compound_initialiser(ret,translation_data))
+ return (struct Initialiser*)ret;
+ else
+ return get_initialiser_error((struct Initialiser*)ret);
}
struct Initialiser* get_initialiser_error(struct Initialiser *error)
{
F diff --git a/src/semantics/value/initialiser.h b/src/semantics/value/initialiser.h --- a/src/semantics/value/initialiser.h +++ b/src/semantics/value/initialiser.h
#include <denoted.h>
#include <queue.h>
#include <type.h>
+ #include <constraints.h>
struct Initialiser
{